Professional Documents
Culture Documents
Link List
Link List
List
University of Sialkot
Definition:-
Abstract Data Types (ADTs) stores data and allow various
operations on the data to access and change it.
A mathematical model, together with various operations
defined on the model
An ADT is a collection of data and associated operations for
manipulating that data
Data Structures
Physical implementation of an ADT
data structures used in implementations are provided in a
language (primitive or built-in) or are built from the language
constructs (user-defined)
Each operation associated with the ADT is implemented
by one or more subroutines in the implementation
Abstract Data Type
Real life:
a. shopping list,
b. groceries list,
c. list of people to invite to dinner
d. List of presents to get
current size
A 2 6 8 7 1
3 5
1 2 3 4 5
current
Step 2: A 2 6 8 9 1
size 5
1 2 3 4 5
5
current
Step 2: A 2 6 8 9 1
size 5
1 2 3 4 5
5
We fill the blank spot left by the removal of 7 by
shifting the values to the right of position 5
over to the left one space.
Algorithms & Data Structures
Implementing Lists
find(X): traverse the array until X is located.
int find(int X)
{
int j;
for(j=1; j < size+1; j++ )
if( A[j] == X ) break;
if( j < size+1 )
{ // found X
current = j; // current points to where X found
return 1; // 1 for true
}
return 0; // 0 (false) indicates not
found
}
Algorithms & Data Structures
Implementing Lists
Other operations:
find
Worst-case: may have to search the entire array
Average-case: search at most half the array.