

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: Stacks
incomplete
2: Stack Speed
incomplete
3: Pop and Peek
incomplete
4: Stack Review
incomplete
5: Using a Stack
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
All supported operations are O(1) by themselves. However, some tasks, like getting to an item at the bottom of the stack have a higher time complexity because they require multiple pop operations.
Stack operations are limited: no searching, no sorting, no random access
Stacks, like all abstract data types, can store items of any type. What makes it a stack is the behavior of the operations, not the type of data it stores.
Stacks are often used in the real world for:
Function call management
Undo/redo functionality
Expression evaluation
Browser history