Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Structure Dr. Mohamed Khafagy. Abstraction.Abstraction is a technique in which we construct a model of an entity based upon its essential Characteristics.

Similar presentations


Presentation on theme: "Data Structure Dr. Mohamed Khafagy. Abstraction.Abstraction is a technique in which we construct a model of an entity based upon its essential Characteristics."— Presentation transcript:

1 Data Structure Dr. Mohamed Khafagy

2 Abstraction.Abstraction is a technique in which we construct a model of an entity based upon its essential Characteristics while ignoring the inessential details..The principle of abstraction also helps in handling the inherent complexity of a system by allowing looking at its important external characteristic, and hiding its inner complexity at the same time..Hiding the internal details is called encapsulation..Engineers of all fields, including computer science, have been practicing abstraction for mastering complexity.

3 Types of data Abstraction.Code and Data abstraction ◦ What is Data ? - What is code ?

4 Advantages of data Abstraction Simplification of software development Testing and Debugging Reusability Modification to representation of a data type etc

5 void selectionSort(int a[],int size) { int I,j,min,temp; for(i=0; i<size-1; i++) { min=i; for(j=i; i<size; j++) { if(a[j]< a[min]) min=j; } temp=a[i]; a[i]=a[min]; a[min]=temp; } }

6 int minimum(int a[],int from,int to) { int min=from; for(int i=from;i<=to;i++) if(a[i] < a[min]) min=i; return min; } void selectionSort(int a[],int size) { int i,j,min; for(i=0;i<size-1;i++){ min=minimum(a,I,size-1) swap(a[i],a[min]); } void swap(int &x, int &y) { int temp=x; x=y; y=temp; }

7 Data Abstraction and Abstract Data Types(ADT) A data type is a template for objects and a set of operations that define the behavior of the objects (or instances) of that type. An Abstract data type (ADT) is a data type in which the implementation details are hidden and the user is concerned with the properties ( or behavior ) of that type. An ADT has two commponents: - Interface – the behavior - Implementation Example: -int,float

8 Abstract Data Type The data structures used to implement the data type can only be accessed through the interface. Any change in the implementation does not change the user programs as long as the interface remains the same. This is also known as data encapsulation or data abstraction. implementation interface1interfece2 interface3interface4

9 Abstraction Vs. Implementation X -> 01000001 01000010 01000011 00000000 X = ? If x is CString -then x -> “ABC” If x is integer - then x -> 1094861568

10 Abstraction Vs. Implementation Two dimensional array 1536 323864 22768299 010634554 User’s view (abstraction) 153632386422768299010634 5 54 System’s view (implementation)

11 ADTs and C++ Classes A class is used to define (and implement) an ADT in C++. A class consists of data and functions that operate on that data. A class in C++ has two parts – public and private (let’s ignore the protected members for now). The data and functions defined in the class are called the members of the class.

12 ADTs and C++ Classes Users of the class can only access and manipulate the class state through the public members of the class. Private members can only be used by other members of the class (let’s also ignore the friends for now). Data encapsulation is achieved by declaring all data members of a class to be private. The interface of the class is provided through the use of public member functions.

13 Data Structures The primary objective of programming is to efficiently process the input to generate the desired output. We can achieve this objective in an efficient and neat style if the input data is organized in a way to help us meet our goal. Data Structures is nothing but ways and means of organizing data so that it can be processed easily and efficiently. Data structures dictate the manner in which the data can be processed. In other words, the choice of an algorithm depends upon the underlying data organization. ( What is an Algorithm ? )

14 Data Structure Operations Traversing Searching Inserting Deleting Sorting Merging Recursion To perform operations on various data structures we use algorithms.

15 Types of Data Structures Premitive/Scalar : data types that can be manipulated as a single quantity or can be represented alone Structured/ Non-Premitive (Data type which is collection of other premitive or non-premitive data structures. ◦ Can be further divided into a) linear b) non-linear - Linear can be further split into a) physically linear b) logically linear


Download ppt "Data Structure Dr. Mohamed Khafagy. Abstraction.Abstraction is a technique in which we construct a model of an entity based upon its essential Characteristics."

Similar presentations


Ads by Google