Stack examples are: a stack of books, a browser back button. You can only insert or delete items from the top or back of the stack.
The Lifo stands for last in first out
- push
- pop
- peek
- length or size
- is_empty
Algorithm | Average | Worst Case |
---|---|---|
Space | O(n) | O(n) |
Search | O(n) | O(n) |
Insert | O(1) | O(1) |
Delete | O(1) | O(1) |
Peek | O(1) | O(1) |