Queues are fast, FIFO-ordered data structures with O(1) Enqueue and Dequeue operations. Use array-backed circular queues for fixed-size scenarios and linked list queues for dynamic scenarios. Four types exist: Simple, Circular, Priority, and Deque.
Cheat Sheet: FIFO, Front/Rear pointers, Enqueue O(1), Dequeue O(1), Circular Queue avoids waste, Priority Queue = by importance.
The Golden Rules of Queues
1. FIFO is the law. First In, First Out. The person who arrives first leaves first.
2. Two pointers, two ends. Front for removal, Rear for insertion. Unlike stacks that use one end.
3. Speed. Enqueue, Dequeue, and Peek should ALWAYS be O(1). If your queue operation is O(n), something is wrong.
Common Traps (Don't Get Tricked!)
Interview Quick Tips:
These are the key takeaways you need for technical interviews and coding exams. Memorize the pitfalls — these are exactly how exam questions try to trick you.
"What is the biggest pitfall of using a linear array-based queue?"
False Overflow — when the Rear pointer reaches the end of the array even though the Front has moved forward, leaving empty slots that can't be reused. The fix is to use a Circular Queue with modulo arithmetic.