ADT is implementation independent. For example, it only describes what a data type list consists (data) and what are the operations it can perform, but it has no information about how the data list is actually implemented.
An Abstract Data Type (ADT) is:
1. set of values
2. set of operations, which can be applied uniformly to all these values
To abstract is to leave out information.
Whereas data structure is implementation dependent, as in the same example, it is about how the List implemented ie., using array or linked list. Ultimately, a data structure is how we implement the data in an abstract data type or a data structure is a implementation of ADT.
A Data Structure is a way of organising of data elements in computer memory in a manner that is convenient to perform operations on it.Each Data Structure mainly specifies the following :
1.Representation of data elemnts
2.Relationship among data elemnts
3.Access methods
Example :
A class is an ADT,
1. list of all data items called instance variables
2. The list of operations on the data items called functions
3. The data representation is all the fields that are contained within the object
If there is no external access to the data representation, you have an abstract data type
the implementation of this ADT is called data structure
we will implement all the functions in a class such that we can perform operations on data.
Stack ADT :
Data :
1. set of int values (as a example)
2. top
Operations :
push()
pop()
makeEmpty()
Data Structure :
Implementation of Stack ADT means we will implement the push,pop,makeEmpty operation so that we can perform operations on the data to serve the required purpose.
No comments:
Post a Comment