A Queue is a fundamental data structure that follows the First-In-First-Out (FIFO) principle.
It's similar to a real-world queue or line, where the first person to enter is the first to
leave. Elements are added at the rear (enqueue) and removed from the front (dequeue) of the queue.
-
Basic Operations:
- Enqueue: Add element to rear
- Dequeue: Remove element from front
- Front/Peek: View first element
- IsEmpty: Check if queue is empty
-
Common Applications:
- Task scheduling in operating systems
- Print job management
- Breadth-first search in graphs
- Request handling in web servers
- Buffer for data streams
-
Key Advantages:
- Simple and intuitive implementation
- Predictable element ordering
- Efficient for FIFO operations