Stacks Flashcards
1
Q
What is a stack?
A
A last in first out (LIFO) data structure where the last item to be added/pushed is the first item to be removed/popped
2
Q
What are some uses of stack:
A
- Performing depth first search (DFS) on graphs
- Backtracking algorithms
- Keeping track of users inputs for undo operations
- Used by processor to track flow of programs
3
Q
What is a stack overflow ?⚠️
A
A stack overflow is an attempt to push an item onto a full stack
4
Q
What is a stack underflow? ⚠️
A
A stack underflow is an attempt to pop of an item of an empty stack