What is abstract data type ? Support your answer with example.
Abstract Data Type (ADT)
An Abstract Data Type (ADT) is a type of data structure that defines what operations can be performed on the data but does not specify how these operations are implemented.
ADT focuses on what to do, not how to do it.
It hides the implementation details and shows only the necessary operations to the user. This concept is based on abstraction in programming.
Key Features of ADT
Example 1: Stack as an ADT
A Stack follows LIFO (Last In First Out) principle.
Operations Defined:
Here, the user only knows these operations.
The stack may be implemented using:
But the implementation is hidden.
User does not know how memory is managed internally.
Example 2: Queue as an ADT
A Queue follows FIFO (First In First Out) principle.
Operations:
Again, implementation may use:
But only operations are exposed.
Conclusion
An Abstract Data Type defines the logical behavior of a data structure without revealing its internal working.
Examples of ADT:
Thus, ADT provides abstraction and makes programming more organized and secure.