Presentation is loading. Please wait.

Presentation is loading. Please wait.

Abstract Data Types, Elementary Data Structures and Arrays

Similar presentations


Presentation on theme: "Abstract Data Types, Elementary Data Structures and Arrays"— Presentation transcript:

1 Abstract Data Types, Elementary Data Structures and Arrays
Lecture 01 Abstract Data Types, Elementary Data Structures and Arrays

2 Abstract data Types Abstract Data Type is an organized collection of information and a set of operations used to manage that information. e.g. Whole numbers (integers) and arithmetic operators for addition, subtraction, multiplication and division. e.g. Flight reservation Basic operations: find empty seat, reserve a seat, cancel a seat assignment Data, operations, and relations are studied independent of implementation. What not how is the focus. Superior Uni- DSA2014 BSSE

3 ADT and DS A data structure is the physical implementation of an ADT.
Abstract data type a new type describes properties and operations Each ADT operation is defined by its inputs and outputs Collection of elements or we can say information. Logical form A data structure is the physical implementation of an ADT. Each operation associated with the ADT is implemented by one or more subroutines in the implementation. How collection is stored in memory Physical/ Concrete form Stack is ADT with push, pop operations, but can we say about stack data structure if I mean I used stack implemented as an array in my algorithm? And why heap isn't ADT Superior Uni- DSA2014 BSSE

4 Data Type ADT: Type Data Items: Operations Logical Form
Data Structure: Storage Space Subroutines Data Items: Physical Form 4 Superior Uni- DSA2014 BSSE

5 Arrays An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier The lowest address corresponds to the first element and the highest address to the last element. One dimensional array Two Dimensional array Superior Uni- DSA2014 BSSE

6 type arrayName [ arraySize ]; double balance[10];
Declaring Arrays: type arrayName [ arraySize ]; double balance[10]; Initializing array double balance[5] = {1000.0, 2.0, 3.4, 17.0, 50.0}; Accessing Array Elements: double salary = balance[9]; Superior Uni- DSA2014 BSSE

7 Superior Uni- DSA2014 BSSE

8 Superior Uni- DSA2014 BSSE

9 Superior Uni- DSA2014 BSSE

10 2D array Simplest form of multidimensional array
A two-dimensional array can be think as a table, which will have x number of rows and y number of columns Most high level languages support arrays with more than one dimension. 2D arrays are useful when data has to be arranged in tabular form. Higher dimensional arrays appropriate when several characteristics associated with data. Superior Uni- DSA2014 BSSE

11 Declaring 2D Array type arrayName [ x ][ y ]; Initializing 2D Array: int a[3][4] = { {0, 1, 2, 3} , {4, 5, 6, 7} , {8, 9, 10, 11} }; or int a[3][4] = {0,1,2,3,4,5,6,7,8,9,10,11}; Accessing Two-Dimensional Array Elements: int val = a[2][3]; Superior Uni- DSA2014 BSSE

12 Superior Uni- DSA2014 BSSE


Download ppt "Abstract Data Types, Elementary Data Structures and Arrays"

Similar presentations


Ads by Google