Stack Flashcards
What is a stack?
A linear data structure that operates on the principle of Last-In, First-Out (LIFO), meaning the most recently added element is the first one to be removed
What are the four key operations that you can perform on a stack?
Push (add), Pop (remove), Peek (see the top element), IsEmpty
What are some use cases of stacks?
- Web Browser History
- Undo Function
- Function Call Management
What is the time complexity of the push operation on a stack?
O(1)
What is the time complexity of the pop operation on a stack?
O(1)
What is the time complexity of the peek operation on a stack?
O(1)
What is the time complexity of the IsEmpty operation on a stack?
O(1)
What is the term for popping an element from an empty stack?
Stack Underflow
What is the term for pushing an element onto a stack that’s already full?
Stack Overflow