1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.

Slides:



Advertisements
Similar presentations
PROGRAMMING LANGUAGE (JAVA) UNIT 42 BY ROBERT BUTTERFIELD TELEPHONE Data Structures and Algorithms.
Advertisements

David Luebke 1 6/7/2014 CS 332: Algorithms Skip Lists Introduction to Hashing.
Symbol Table.
Data Structures.
COMPSCI 105 S Principles of Computer Science 12 Abstract Data Type.
Lecture - 1 on Data Structures. Prepared by, Jesmin Akhter, Lecturer, IIT,JU Data Type and Data Structure Data type Set of possible values for variables.
CMPT 225 Data Structures and Programming. Course information Lecturer: Jan Manuch (Jano), TASC TAs: Osama Saleh,
Welcome CS 315 Data Structures. Instructor: B. Ravikumar Office: 116 I Darwin Hall Phone: Course Web site:
Data Structures & Algorithms What The Course Is About s Data structures is concerned with the representation and manipulation of data. s All programs.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
CS 315 Data Structures B. Ravikumar Office: 116 I Darwin Hall Phone: Course Web site:
1 Data Structures A program solves a problem. A program solves a problem. A solution consists of: A solution consists of:  a way to organize the data.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
1 ES 314 Advanced Programming Lec 3 Sept 8 Goals: complete discussion of pointers discuss 1-d array examples Selection sorting Insertion sorting 2-d arrays.
Chapter 1 Principles of Programming and Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
DAST, Spring © L. Joskowicz 1 Data Structures – LECTURE 1 Introduction Motivation: algorithms and abstract data types Easy problems, hard problems.
Chapter 1 Introduction Definition of Algorithm An algorithm is a finite sequence of precise instructions for performing a computation or for solving.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
Introduction - The Need for Data Structures Data structures organize data –This gives more efficient programs. More powerful computers encourage more complex.
DATA STRUCTURE Subject Code -14B11CI211.
Data Structures and Programming.  John Edgar2.
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
Copyright © Wondershare Software Introduction to Data Structures Prepared by: Eng. Ahmed & Mohamed Taha.
Comp 245 Data Structures Software Engineering. What is Software Engineering? Most students obtain the problem and immediately start coding the solution.
Introduction to Data Structures & Algorithm. Objectives: By the end of the class, students are expected to understand the following: data structure and.
ADTs and C++ Ch 2,3,4 May 12, 2015 Abstract Data Type (ADT) An abstract data type is: 1.A collection of data items (storage structures) 2.Basic operations.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture8.
Hashing Table Professor Sin-Min Lee Department of Computer Science.
Prepared By Ms.R.K.Dharme Head Computer Department.
1 CSC 222: Computer Programming II Spring 2004 See online syllabus at: Course goals:
Chapter 9 (modified) Abstract Data Types and Algorithms Nell Dale John Lewis.
1 Life Cycle of Software Specification Design –Risk Analysis –Verification Coding Testing –Refining –Production Maintenance.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
DATA STRUCTURE & ALGORITHMS (BCS 1223) NURUL HASLINDA NGAH SEMESTER /2014.
Chapter 1 Data Structures and Algorithms. Primary Goals Present commonly used data structures Present commonly used data structures Introduce the idea.
Software Engineering Principles. SE Principles Principles are statements describing desirable properties of the product and process.
Data Abstaraction Chapter 10.
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.
Data Structures and Algorithm Analysis Introduction Lecturer: Ligang Dong, egan Tel: , Office: SIEE Building.
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
Data Structures Using C++ 2E
1 CSC 427: Data Structures and Algorithm Analysis Fall 2006 See online syllabus (also available through Blackboard): Course goals:
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Software Engineering and Object-Oriented Design Topics: Solutions Modules Key Programming Issues Development Methods Object-Oriented Principles.
Topic 2 Collections. 2-2 Objectives Define the concepts and terminology related to collections Discuss the abstract design of collections.
CS 315 Data Structures Fall 2011 Instructor: B. (Ravi) Ravikumar Office: 116 I Darwin Hall Phone: Course Web site:
Introduction to Objects and Encapsulation Computer Science 4 Mr. Gerb Reference: Objective: Understand Encapsulation and abstract data types.
 Saturday, April 20, 8:30-11:00am in B9201  Similar in style to written midterm exam  May include (a little) coding on paper  About 1.5 times as long.
Chapter 2 Principles of Programming and Software Engineering.
Constructs for Data Organization and Program Control, Scope, Binding, and Parameter Passing. Expression Evaluation.
ARRAYS IN C/C++ (1-Dimensional & 2-Dimensional) Introduction 1-D 2-D Applications Operations Limitations Conclusion Bibliography.
Principles of Programming. Achieving an Object-Oriented Design  Abstraction and Information Hiding  Object-Oriented Design  Functional Decomposition.
BITS Pilani Pilani Campus Data Structure and Algorithms Design Dr. Maheswari Karthikeyan Lecture1.
CSC 143T 1 CSC 143 Highlights of Tables and Hashing [Chapter 11 p (Tables)] [Chapter 12 p (Hashing)]
CS 315 Data Structures Spring 14 Instructors (lecture) Bala Ravikumar Office: 116 I Darwin Hall Phone: piazza, (Lab.
Introduction toData structures and Algorithms
Principles of Programming & Software Engineering
CSC 427: Data Structures and Algorithm Analysis
Introduction to Algorithms
CS 315 Data Structures B. Ravikumar Office: 116 I Darwin Hall Phone:
GC211Data Structure Lecture2 Sara Alhajjam.
DATA STRUCTURES AND OBJECT ORIENTED PROGRAMMING IN C++
Principles of Programming and Software Engineering
Introduction to Algorithms
Chapter 2. Problem Solving and Software Engineering
Presentation transcript:

1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers

2 Object-Oriented Design Coding without a solution design increases debugging time A team of programmers for a large software development project requires –An overall plan –Organization –Communication Software engineering –Provides techniques to facilitate the development of computer programs

3 An Examination of Problem Solving Problem solving –The process of taking the statement of a problem and developing a computer program that solves that problem Object-oriented analysis and design (OOA / D) –A process for problem solving –A problem solution is a program consisting of a system of interacting classes of objects Each object has characteristics and behaviors related to the solution A class is a set of objects having the same type

4 Abstraction and Information Hiding Abstraction –Separates the purpose of a module from its implementation –Specifications for each module are written before implementation –Functional abstraction Separates the purpose of a module from its implementation

5 Abstraction and Information Hiding –Data abstraction Focuses on the operations of data, not on the implementation of the operations –Abstract data type (ADT) A collection of data and a set of operations on the data You can use an ADT’s operations without knowing their implementations or how data is stored, if you know the operations’ specifications

6 Abstraction and Information Hiding –Data structure A construct that you can define within a programming language to store a collection of data –Develop algorithms and ADTs in tandem

7 Abstraction and Information Hiding Information hiding –Hide details within a module –Ensure that no other module can tamper with these hidden details –Public view of a module Described by its specifications –Private view of a module Implementation details that the specifications should not describe

8 Principles of Object-Oriented Programming Object-oriented languages enable us to build classes of objects A class combines –Attributes (characteristics) of objects of a single type Typically data Called data members –Behaviors (operations) Typically operate on the data Called methods or member functions

9 What is a Good Solution? A solution is good if: –The total cost it incurs over all phases of its life cycle is minimal The cost of a solution includes: –Computer resources that the program consumes –Difficulties encountered by users –Consequences of a program that does not behave correctly Programs must be well structured and documented Efficiency is one aspect of a solution’s cost

10 Key Issues in Programming 1.Modularity 2.Style 3.Modifiability 4.Ease of Use 5.Fail-safe programming 6.Debugging 7.Testing

11 Modularity Modularity has a favorable impact on –Constructing programs –Debugging programs –Reading programs –Modifying programs –Eliminating redundant code

12 Style 1.Use of private data members 2.Proper use of reference arguments 3.Proper use of methods 4.Avoidance of global variables in modules 5.Error handling 6.Readability 7.Documentation

13 Data Structures – key to software design Data structures play a key role in every type of software. Data structure deals with how to store the data internally while solving a problem in order to Optimize the overall running time of a program Optimize the response time (for queries) Optimize the memory requirements Optimize other resources (e.g. band-width of a network) Simplify software design make solution extendible, more robust

14 Abstract vs. concrete data structures Abstract data structure (sometimes called ADT -> Abstract Data Type) is a collection of data with a set of operations supported to manipulate the structure Examples: –stack, queue insert, delete –priority queue insert, deleteMin –Dictionary insert, search, delete Concrete data structures are the implementations of abstract data structures: –Arrays, linked lists, trees, heaps, hash table A recurring theme: Find the best mapping between abstract and concrete data structures.

15 Abstract Data Structure (ADT) supporting operations Dictionary search insert primary operations Delete deleteMin Range search Successor secondary operations Merge Priority queue Insert deleteMin Merge, split etc. Secondary operations primary operations

16 Linear data structures key properties of the (1-d) array: a sequence of items are stored in consecutive memory locations. array provides a constant time access to k-th element for any k. (access the element by: Element[k].) inserting at the end is easy. if the current size is S, then we can add x at the end using the single instruction: Element[S++] = x; deleting at the end is also easy. inserting or deleting at any other position is expensive. Even searching is expensive (unless sorted).

17 Linked lists Linked lists: –Storing a sequence of items in non- consecutive locations of the memory. –Not easy to search for a key (even if sorted). –Inserting next to a given item is easy. –In doubly linked list, inserting before or after a given item is easy. –Don’t need to know the number of items in advance. (dynamic memory) order is important

18 stacks and queues stacks: insert and delete at the same end. equivalently, last element inserted will be the first one to be deleted. very useful to solve many problems Processing arithmetic expressions queues: insert at one end, deletion at the other end. equivalently, first element inserted is the first one to be deleted.

19 Priority queues insert, deleteMin – main operations merge, split, etc. – secondary operations expected performance: number of operations performed for insert and deletemin – should both be much smaller than n, the number of keys in the queue.

20 Hashing dictionary operations expected performance constant time on average for each of the operations search, insert and delete.

Arrays and pointers variable name variable value address – a binary number used by the operating system to identify a memory cell of RAM It is important to know the precise meanings of these terms

Memory Terminology (cont.) Addresses x15

Memory Terminology (cont.) Addresses x 15 Variable name

Memory Terminology (cont.) Addresses x 15 A variable (which is a location)

Memory Terminology (cont.) Addresses x15 Value of the variable

Memory Terminology (cont.) Addresses x 15 Address of the variable

27 Array Example Write a program that finds the largest number in a given collection of keys. Assume the numbers are stored in an array. int max (int[] A, int size)

28 Array Example Write a program that finds the largest number in a given collection of keys. Assume the numbers are stored in an array. int max (int[] A, int size) { if (size == 0) return 0; int temp = A[0]; for (int j = 1; j < size; ++j) if (temp < A[j]) temp = A[j]; return temp; }

29 Implementation using a vector

30 Notion of time complexity int max (int[] A, int n) { if (n == 0) return 0; int temp = A[0]; for (int j = 1; j < size; ++j) if (temp < A[j]) temp = A[j]; return temp; } What is the total number of operations performed by the above procedure (as a function of n )? Assignment, comparison, return – each costs one unit.