Overview
A stack is a data structure that stores items according to the Last In First Out (LIFO) principle. The most recently added item is the first one to be removed.| Operations | Complexity |
|---|---|
| Push (insert end) | O(1) |
| Pop (delete last) | O(1) |
| Peek (view last) | O(1) |
Implementation
Stacks can be implemented using different underlying structures. The most common versions are based on arrays or linked lists.Array Based Stack
Array Based Stack
Linked List Based Stack
Linked List Based Stack