Stacks & Queues Flashcards
1
Q
What is a stack? What are its key operations?
A
LIFO (Last In, First Out), operations: push(), pop(), peek().
2
Q
What is a queue? How does it differ from a stack?
A
FIFO (First In, First Out), operations: enqueue(), dequeue().
3
Q
How does a priority queue work?
A
Elements are dequeued in order of priority rather than order of insertion.
4
Q
In a min priority q where are the smallest elements?
A
the root