5.1 and 5.4 through 5.6 Various Things. Terminology Identifiers: a name representing a variable, class name, method name, etc. Operand: a named memory.

Slides:



Advertisements
Similar presentations
Recursion vs. Iteration The original Lisp language was truly a functional language: –Everything was expressed as functions –No local variables –No iteration.
Advertisements

COMPSCI 105 S Principles of Computer Science 12 Abstract Data Type.
Software Engineering and Design Principles Chapter 1.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Complexity Analysis (Part I)
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Recursion.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Chapter 1 Principles of Programming and Software Engineering.
Cmp Sci 187: Midterm Review Based on Lecture Notes.
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
C++ fundamentals.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
1 Shawlands Academy Higher Computing Software Development Unit.
Comp 249 Programming Methodology Chapter 15 Linked Data Structure - Part B Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
9/17/20151 Chapter 12 - Heaps. 9/17/20152 Introduction ► Heaps are largely about priority queues. ► They are an alternative data structure to implementing.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
Recursion Chapter 7. Chapter Objectives  To understand how to think recursively  To learn how to trace a recursive method  To learn how to write recursive.
CSC 212 Object-Oriented Programming and Java Part 1.
Unit III : Introduction To Data Structures and Analysis Of Algorithm 10/8/ Objective : 1.To understand primitive storage structures and types 2.To.
COP3530 Data Structures600 Stack Stack is one the most useful ADTs. Like list, it is a collection of data items. Supports “LIFO” (Last In First Out) discipline.
Chapter 12 Recursion, Complexity, and Searching and Sorting
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Stephen P. Carl - CS 2421 Recursion Reading : Chapter 4.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
APCS Java AB 2004 Review of CS1 and CS2 Review for AP test #1 Sources: 2003 Workshop notes from Chris Nevison (Colgate University) AP Study Guide to go.
1 CSC 222: Computer Programming II Spring 2004 See online syllabus at: Course goals:
Chapter 11 Heap. Overview ● The heap is a special type of binary tree. ● It may be used either as a priority queue or as a tool for sorting.
Complexity of Algorithms
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Object Oriented.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
Introduction to Data Structures and Algorithms CS 110: Data Structures and Algorithms First Semester,
CSC 221: Recursion. Recursion: Definition Function that solves a problem by relying on itself to compute the correct solution for a smaller version of.
Chapter 12 Support for Object oriented Programming.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
The Software Development Process
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson Slides4-2.ppt Modification date: March 23, Procedures Essential ingredient of high level.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
CHP-3 STACKS.
Introduction to OOP CPS235: Introduction.
Winter 2006CISC121 - Prof. McLeod1 Stuff No stuff today!
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
2005MEE Software Engineering Lecture 7 –Stacks, Queues.
Introduction to Objects and Encapsulation Computer Science 4 Mr. Gerb Reference: Objective: Understand Encapsulation and abstract data types.
1 5. Abstract Data Structures & Algorithms 5.1 Data Structure Fundamentals.
Chapter 1 The Phases of Software Development. Software Development Phases ● Specification of the task ● Design of a solution ● Implementation of solution.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
1 Algorithms Searching and Sorting Algorithm Efficiency.
CS 116 Object Oriented Programming II Lecture 13 Acknowledgement: Contains materials provided by George Koutsogiannakis and Matt Bauer.
CPS120: Introduction to Computer Science Sorting.
Algorithms and Problem Solving
Visit for more Learning Resources
Lecture 2 of Computer Science II
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Stacks Chapter 4.
Introduction to Data Structure
Presentation transcript:

5.1 and 5.4 through 5.6 Various Things

Terminology Identifiers: a name representing a variable, class name, method name, etc. Operand: a named memory location or object manipulated by the program. Variables are operands and identifiers – Ex: In “var1 + 45”, var1 is an identifier and operand, while 45 is only an operand. Operator: Indicate action to be applied to operands – i.e. +, -, /, and, or, xor, not, etc.

Terminology (Continued) Unary Operator: An operator that requires only one operand. – Ex: Negation in boolean expressions, or x++ in Java. Binary Operator: An operator that requires 2 operands, like + in x + y

Terminology (Continued) (Continued) Actual Parameter, or argument: The variable names that a method calls for – In DoStuff(x), the actual parameter/argument is x. Formal Parameter: The variables sent to a method. Parameters get their values from arguments.

Passing By-Value and By-Reference By-Value: The value is sent, not a reference to the original variable. It’s a “copy”. By-Reference: The original variable is used. If the parameter is manipulated, the original will be, too. Most things in Java are sent by-value. Arrays, java classes, and user-defined objects are passed by reference. Java doesn’t allow primitive data types (int, char, etc.) to be passed by-reference.

Data Structures The way data is organized LIST data structures store a sequence of the same data type Stacks, Queues, and Binary Trees are examples of lists

Stacks A stack is simple. Think of objects being stacked on top of each other. When an object is added to the stack, it always goes on top. This is called PUSHing. When an object is removed from the stack, it is always the top one, and it is removed. This is called POPping. You cannot PUSH into a full stack, or POP from an empty stack. However, a stack can be implemented as a linked list, giving it no maximum except available memory.

Queues Queue: noun: a file or line, esp. of people waiting their turn. A queue in Java is the programming equivalent to this. Items are taken from the front of the queue, but they’re not added to the front (like in stacks). Instead, they’re added to the back. Called a First-In-First-Out (FIFO) Data Structure

Parity Checking Simple error detection Uses “parity bits” to check that data is communicated properly. A parity bit is a bit added to binary data to ensure that the number of 1s is even or odd. – Ex: for odd parity checking, is changed to , to keep the number of 1s odd. – Ex: for even parity checking, is changed to , to make the number of 1s even.

Parity Checking (continued) When the data is received, the receiving program checks to see if there are an even or odd number of 1s in binary information (depending on if it’s even or odd parity checking). – If not, then an error in data transmission has occurred. NOTE: Odd parity checking and even parity checking are the same, except for the number of 1s.

Object Oriented Program

Object Oriented Programming The kind of programming you’ve been doing (Java is object-oriented) Object Oriented Programming is the use of objects (classes) to make programming modular. This way, programs can be better organized, and specific parts of programs can be more easily reused.

Features of an Object Functions – return values Procedures – perform a task, but don’t return a value Object – a combination of data and operations – Objects can be modified Data Items – pretty much data – Can be made private or public

Object Class Object is the root of the class hierarchy. – Every class has Object as a superclass. All objects, including arrays, implement the methods of this class. Object class rules everything

Encapsulation Basically this is the ability to hide variable information from other parts of the program I.E. private variables

Advantages of encapsulation Less variables to manage; the programmer only has to know what a method does in order to use it Less prone to errors Large applications are easier to maintain since objects may be updated and recompiled as necessary

Polymorphism Polymorphism is the capability of an action or method to do different things based on the object that it is acting upon Examples – Overwriting – Concatenation – Overloading – Applets

Inheritance The ability to derive new classes from existing classes New methods have the same name as the superclass, but override them I.E. Automobile class – Subclass car – Subclass truck – Subclass motorcycle

Advantages of Objects Faster development Increased quality of software, more robust Easier maintenance Implementation details are hidden Enhances reusability and modification

desventajes Private variables can cause programmers to have difficulty debugging Many computer languages do not support objects, transferring them would be costly Simple programs take longer to make Lack of standardized approach on how to implement objects

Recursion

What is recursion? Recursion is the process of repeatedly calling a function from within the definition of the function itself. The function must be able to terminate (aka loop that ends) After the process is terminated the solutions and calculations are processed

Advantages Less variables Fewer lines of code

Disadvantages Can take longer than other methods Slower than iterative equivalent Tricky to follow Clear documentation is required Difficult to maintain

Algorithm Evaluation

Efficiency of Algorithms Time required depends on processor speed and algorithm design Example: Linear Search – List has a size of n Best case scenario time required is 1 Worst case scenario time required is n Depends a lot on how program is written

What’s Necessary to Know Single loops are O(N) A nested loop is O(N 2 ) More than that is different, but probably not necessary for IB tests. However…

Various Sorts and their Efficiency

Big O Notation Big O “lives in the land of theory and doesn’t care very much about the real world” Big O describes how the algorithm scales (performs) in the worst case scenario as it is is run with more input Big-O can also be used to describe other behavior such as memory consumption O(N), N = number of elements aka time required

What Big O is not The Big-O is not concerned with factors that do not change as the input increases. Big O does not care about extra RAM or anything done to the computer to make it faster. The only thing Big-O is concerned with is the speed relative to other algorithms (instead of actual speed).

What Big O is Good indicator of what algorithm to use once you take your individual circumstances into consideration Works great for optimization Big-O of a given algorithm combined with the specific problem knowledge is a great way to choose the best algorithm for your situation

Remember These Big-O means worst-case – Big-O gives an upper-bound Big-Omega means best-case – Big-Omega gives an lower-bound. Big-Theta means average-case The above are oversimplifications, but it’s a good way to remember things.