Stack
A stack is a linear abstract data type which operates in LIFO (last in first out) order. Because it is an abstract data type, it can be implemented under the hood with arrays, linked-list or other more concrete data structures. Linked lists are a common choice because in a linked list the necessary operations are O(1) (constant time).
Operations
- Push: Adds an item to the top of the stack
- Pop: Retrieves and removes the top item from the stack
- Peek: Retrieves the top item from the stack, but does not remove it