- Stack = last in, first out: push, pop, top, size, isEmpty.
🎯 How this can come up · 1 question
After push(1), push(2), push(3), pop(), the top is:
Correct: 2.
- Array stack: O(1) operations but fixed capacity.
- Parentheses matching: push openers, pop and compare on closers; stack empty at the end = balanced.
🎯 How this can come up · 1 question
How does a stack check that ( [ { } ] ) is balanced?
Scan left to right: push every opening symbol; on a closing symbol pop and check it matches. If a pop finds the stack empty or a mismatch, it’s unbalanced; at the end the stack must be empty.
- Expression evaluation uses an operator stack and a value stack with precedence.
- Queue = first in, first out: enqueue, dequeue, first.
🎯 How this can come up · 1 question
enqueue(1), enqueue(2), enqueue(3), dequeue() returns:
Correct: 1.
- Circular array queue: f (front index) and size; r = (f + size) mod N.
🎯 How this can come up · 1 question
In a circular array queue of capacity N, the index after r is:
Correct: (r + 1) mod N.
- Round robin with a queue: dequeue, serve, enqueue.
- Array queue and linked queue: all operations O(1).
No slides match this filter.