2016-07-021 Prof. I. J. Chung Data Structure #1 Professor I. J. Chung.

Slides:



Advertisements
Similar presentations
1 Classes and Data Abstraction Chapter What a Class ! ! Specification and implementation Private and public elements Declaring classes data and.
Advertisements

Chapter 4&5 Defining Classes Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
COMPSCI 105 S Principles of Computer Science 12 Abstract Data Type.
Road Map Introduction to object oriented programming. Classes
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Chapter 3 Data Abstraction: The Walls. © 2005 Pearson Addison-Wesley. All rights reserved3-2 Abstract Data Types Modularity –Keeps the complexity of a.
1 Chapter 11 Structured Types, Data Abstraction and Classes Dale/Weems/Headington.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Information Hiding and Encapsulation
Rossella Lau Lecture 5, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 5: Class construction  Encapsulation 
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Chapter 11: Classes and Data Abstraction
Lecture 9 Concepts of Programming Languages
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Abstract Data Types and Encapsulation Concepts
C++ fundamentals.
Introduction - The Need for Data Structures Data structures organize data –This gives more efficient programs. More powerful computers encourage more complex.
Data Structures 1- Course Syllabus. 2- Introduction about Data Structures.
IT PUTS THE ++ IN C++ Object Oriented Programming.
Introduction to Object-oriented programming and software development Lecture 1.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
The Java Programming Language
Two Parts of Every ADT An abstract data type (ADT)  is a type for encapsulating related data  is abstract in the sense that it hides distracting implementation.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
1 Chapter Structured Types, Data Abstraction and Classes Dale/Weems.
P Chapter 2 introduces Object Oriented Programming. p OOP is a relatively new approach to programming which supports the creation of new data types and.
CSSE501 Object-Oriented Development. Chapter 4: Classes and Methods  Chapters 4 and 5 present two sides of OOP: Chapter 4 discusses the static, compile.
Chapter 4 Data Abstraction: The Walls. © 2004 Pearson Addison-Wesley. All rights reserved4-2 Abstract Data Types Modularity –Keeps the complexity of a.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Views of Data Data – nouns of programming world the objects that are manipulated information that is processed Humans like to group information Classes,
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
Data Structures Using C++ 2E
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
1 CS 311 Data Structures. 2 Instructor Name : Vana Doufexi Office : 2-229, Ford Building Office hours: By appointment.
1 CS Programming Languages Class 22 November 14, 2000.
(1) ICS 313: Programming Language Theory Chapter 11: Abstract Data Types (Data Abstraction)
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 05: Classes and Data Abstraction.
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
72 4/11/98 CSE 143 Abstract Data Types [Sections , ]
YG - CS Concept of Encapsulation What is encapsulation? - data and functions/methods are packaged together in the class normally.
CPSC 252 ADTs and C++ Classes Page 1 Abstract data types (ADTs) An abstract data type is a user-defined data type that has: private data hidden inside.
1 Classes and Data Abstraction Chapter What a Class ! ! Specification and implementation Private and public elements Declaring classes data and.
XuanTung Hoang 1 Something to discuss Feedbacks on Midterm Exam Final exam and term project  Final exam requires solid knowledge/skills in Java  Be more.
Maitrayee Mukerji. INPUT MEMORY PROCESS OUTPUT DATA INFO.
1 Chapter 12 Classes and Abstraction. 2 Chapter 12 Topics Meaning of an Abstract Data Type Declaring and Using a class Data Type Using Separate Specification.
Advanced Data Structures Lecture 1
Introduction toData structures and Algorithms
Principles of Programming & Software Engineering
Chapter 12 Classes and Abstraction
Data Abstraction: The Walls
Algorithms and Problem Solving
Abstract Data Type.
Classes and OOP.
GC211Data Structure Lecture2 Sara Alhajjam.
COMPUTER 2430 Object Oriented Programming and Data Structures I
Chapter 3: Using Methods, Classes, and Objects
About the Presentations
Lecture 9 Concepts of Programming Languages
Abstract Data Types and Encapsulation Concepts
Chapter 3 Introduction to Classes, Objects Methods and Strings
Classes and Data Abstraction
Introduction to Data Structure
Data Abstraction: The Walls
Lecture 9 Concepts of Programming Languages
Presentation transcript:

Prof. I. J. Chung Data Structure #1 Professor I. J. Chung

Prof. I. J. Chung Data Structure program = algo. + d/s algo = logic (what) + control (how) algo : finite set of instructions which accomplish a given particular task (abstract form of pgm) d/s : object to organize and to manipulate data in computer system y = f(x) y : output f(x) : algorithm x : input algo. precond. postcond.

Prof. I. J. Chung Data Structure specification of program : precondition & postcondition precondition : a set of conditions that must be true when a proc. is called if the algo. is to work properly. C++ : assert() eg. : assert(input >= 0); postcondition : a set of conditions to be true after the algo. terminates.

Prof. I. J. Chung Data Structure I <- 0 S <- 0 N = N 0 >= 1 I < N f S = I I +1 S S + (I **3) 1 = 1 Λ S = Λ N = N 0 >= 1 /* m <= n */ precond. s = 0; for (i = m; i <= n ; i++) s += I; /* s is the sum of the #s from m to n */ postcond. L.I :

Prof. I. J. Chung Data Structure data type kinds of data of vars for a PL eg. F : INT, REAL, LOGICAL, COMPLEX, DOUBLE, PRECISION,... PL/1 : CHAR, INT, … C, Ada : allows one to construct combinations of the built-in types Pascal : RECORD C : struct Program TD with Problem Decomposition decompose a task into subtasks until ∀ subtask is easier to solve Divide & Conquer : deviding of original problem into subproblems

Prof. I. J. Chung Data Structure Steps of program 1) specification define the problem to be solved by C/S clearly & definitely, give precond. & postcond. 2) design construct an algo. & d/s (abstraction of program) 3) coding convert the algo. & ds. with the concrete, specific PL 4) testing & execution test the above program witht various data sets 5) maintenance over time, modify the ___ tested program whenever necessary for the new changed case problem

Prof. I. J. Chung Data Structure D.S : logical / mathematical model of a particular data org. D.S D : domain F : function A : axioms ( semantics of operations ) Eg. : E = { nat_#, bool } F = { ZERO, SUCC, ADD, ISZERO } A =

Prof. I. J. Chung Data Structure structure NATURAL_# dclZERO() → natural_# ISZERO ( natural_# ) → boolean SUCC ( natural_# ) → boolean ADD ( natural_#, natural_# ) → boolean EQ ( natural_#, natural_# ) → boolean for all x, y ∈ natural_#, let ISZERO (ZERO) = true : ISZERO(SUCC (X)) = false ADD(ZERO, y) = y, ADD(SUCC (x), y) = SUCC(ADD(x, y)) EQ(x, ZERO) = if ISZERO(x) then true else false EQ(ZERO, SUCC(y)) = false EQ(SUCC (x), SUCC(y)) = EQ(x, y) end end NATURAL_# A

Prof. I. J. Chung Data Structure OOP : programming approach in which data occurs in packages, called the objects, where object ops are executed with member function (C++ : class) programming approach to support the creation of new d.t. & ops to manipulate those types object : encapsulated (packaged together, possibly hidden) data instance of a class OOP : objects have data members & member functions (C++ : objects are created by classes)

Prof. I. J. Chung Data Structure class of C++ : supports information hiding. ie, the user of C++ doesn ’ t have to know how the class is implemented. ie, C++ class can completely hide the knowledge of how the class is implemented. class : defines how to store [ (thru. fields) ] and access [ ( thru. methods) ] all objects of this type. class = data + member function [constructor : method to create a new object] class of C++ : data values are typically private. : can only manipulate class using public member functions

Prof. I. J. Chung Data Structure class : set of member vars & ops. ∃ 2 sorts of vars & ops 1)public : accessible by all mothods including those outside of the class defn. 2)private : accessible only by methods defined in the class ie, private member vars : we cannot directly access the information. the unique access way is to ____ function that we provide for the class. visible any where visible only with the class

Prof. I. J. Chung Data Structure ADT : set of ops with data objects mathematical d.t. for the inf. hiding of d.t. a class that is presented to other programmers with inf. hiding mathematical abstraction of d.t. for implementation – ind. (inf, hiding) (inf. hiding, encapsulation of d.t.) defn : d.t. whose ops are ind. of its specific implementations

Prof. I. J. Chung Data Structure inf. hiding : A d.t. is organized in such a way that the spec of the objects and the specs of the ops on the objects is separated from the rep. of the objects & the implementation of the operations. spec + implementation separation (Ada : package, C++, class)

Prof. I. J. Chung Data : nowhere in an ADT ’ s defn, is there any mention of how the operations is implemented → extension of modular & OOP design. objects s.a. list, set, graph with their ops can be viewed as ADT, just as int, real, booleans are d.t. These have ops, so does the ADT such as ⋃, ⋂, size, complement ADT classes & methods of C++ class : implementation of ADT in C++

Prof. I. J. Chung Data Structure + of ADT : 1)integrity : ADT supports a correct implementation of ops 2)reusability : ADT supports that data objects can be re-used in different user programs 3)extensibility : ADT provides more operations and enhances the efficiency of program 4)simplicity : ADT allows the user to free from the tedious task of implementation detail

Prof. I. J. Chung Data Structure data type : collection of objects with the operations that act on these objects collection of values (domains) with ops on these values basic d.t. : integer, double, string, etc to use a d.t. on a computer specific rep. is necessary. Eg. integer is typically rep. with 4 bytes. → the rep. of d.t. affects the storage size, precision, efficiency, etc. differences between ADT & d.s. d.s. : used to implements an ADT ADT : can be implemented with different structures. so, d.s. is a particular implementation of ADT

Prof. I. J. Chung Data Structure implementation of ADT C++ : define a class classes have member vars & member functions (ops) An object is a var where the d.t. is a class. var & ops of class 1)private : accessible only by methods defined in the class 2)public : accessible by all methods including those outside the class defn. To insure ∀ class object is properly initialized before any client use occurs, a construct is added to the class constructor : member function with 1)automatically invoked upon declaration 2)must be same name as class 3)no return value, not even void

Prof. I. J. Chung Data Structure ADT classes & Members Example class ADTList {// class header public :// public section ADTList () ;// class constructor boolis_emply() const;// methods c member f(n) can ’ t change the object instance int size() const; void remove_All(); void add (int item, int index=0); int get (int index) const; void remove (int index);

Prof. I. J. Chung Data Structure private ://private section static const int MAX_SIZE = 100; int items [MAX_SIZE];//array d.s. int numItem; };//end of class // this class is stored C++ file ADTList.h ADT using a class #include #include “ ADTList.h ”