Describe why a class is ADT (Abstract Data Type)? Why a stack is ADT?
Answer :
A Class usually contains various objects which implies a set of various data members along with their set of operations that are needed to be performed. And the member methods of class handles the instance variables. When a class is used as a type it provides only the essentials and hide the details . That's why the class is considered as ADT (Abstract Data Type).
Stack is considered as ADT (Abstract Data Type) because stack works on the principle of LIFO (last in first out), generally a stack is performed using the two fundamental operations which are PUSH and POP. Stack hides its implementation using arrays or linked lists but it organizes the data in logical and oredered manner.
Since stack hides the details and provides only the essentials, that's why stack is considered as ADT (Abstract Data Type).
NOTE: Queue is also considered as ADT (Abstract Data Type)
Thank You!!!
Get Answers For Free
Most questions answered within 1 hours.