Push
Place an item on top. Nothing else moves, so it is O(1).
Stack: Push, pop, peek
push 5 and it lands on top. Size 1.
Cost
- Best
- O(1)
- Average
- O(1)
- Worst
- O(1)
- Space
- O(1)
Before this
Taught by the same lesson
Stack covers these too, in the same run.
Place an item on top. Nothing else moves, so it is O(1).
push 5 and it lands on top. Size 1.
Stack covers these too, in the same run.