Abstract Data Types
Last updated
Last updated
In computer science, an abstract data type (ADT) is a mathematical model for data types.
An abstract data type is defined by its behavior (semantics) from the point of view of a user, of the data, specifically in terms of possible values, possible operations on data of this type, and the behavior of these operations.
A stack is a Last-In First-Out (LIFO) abstract data structure
Attributes: A container that holds multiple data
Methods:
Push
→ Adds Element to the top of the stack
Pop
→ Removes the most recently added Element
Peek
→ Look at the most recent element
Optional Methods:
size()
-> Returns the number of items in the Stack
isEmpty()
-> Returns True if the stack is empty
All of stack operations are O(1)
with Space complexity being O(n)
.