Queue
The notes
FIFO: first-in, first-out principle
Insertion happens at the rear (tail) and removal happens at the front (head).
Basic queue operations
- 1. Enqueue (insertion): adds an element to the back; check whether the queue is full
- 2. Dequeue (removal): removes and returns the element from the front; check whether the queue is empty
- 3. Peek / front: views the front element without removing it
Implementation
Array-based
- Index positions with a head pointer and a tail pointer
Linked list-based
- A front pointer and a rear pointer
Real-world applications
- Print spooling (tasks wait for the printer)
- Call center systems (waiting calls)
- CPU task scheduling (managing multiple tasks)
- Router buffers
Data structures deck
Make them stick
Sign in to see every card full size, tick the ones you've got, come back to the rest later, and keep your own notes on each card.
Watch the lesson
Data structures, Lesson 1, from 0:53: The Queue Data Structure








