Correct option is A
A stack is LIFO: both push and pop occur at the top—a single logical end.
A queue is FIFO: enqueue occurs at the rear and dequeue at the front, thus using two ends.
Both can be implemented with arrays or linked lists; neither data structure inherently “requires” a specific underlying storage.
Operation costs are O(1) when implemented properly (e.g., maintaining head/tail pointers).
Circular queues avoid costly element shifting in array implementations.
Therefore, only (a) captures the fundamental operational difference.
Both can be implemented with arrays or linked lists; neither data structure inherently “requires” a specific underlying storage.
Operation costs are O(1) when implemented properly (e.g., maintaining head/tail pointers).
Circular queues avoid costly element shifting in array implementations.
Therefore, only (a) captures the fundamental operational difference.
Important Key Points
- Stack (LIFO): push, pop, peek at one end (top).
- Queue (FIFO): enqueue at rear, dequeue at front (two ends).
- Implementations: Arrays or linked lists work for both; choice affects resizing and memory overhead.
- Complexities: Amortized O(1) for dynamic arrays; strict O(1) for linked lists with proper pointers.
- Variants: Deque supports insert/remove at both ends; priority queue orders by key, not arrival time.
- Use cases: Stacks for recursion/undo; queues for scheduling/buffering/level-order traversal.
Knowledge Booster
- Why (b) is wrong: Queues don’t require linked lists; arrays/circular buffers are common.
- Why (c) is wrong: Reverses the truth—stacks use one end; queues use two.
- Why (d) is wrong: Neither structure requires a linked list; both have multiple valid implementations.