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

  1. 1. Linear vs non-linear
  2. 2. Arrays
  3. 3. Hashmaps
  4. 4. Stacks
  5. 5. Queue
  6. 6. Linked list
  7. 7. Binary tree
  8. 8. BST
  9. 9. Graphs
  10. 10. Heaps

Watch the lesson

Data structures, Lesson 1, from 0:53: The Queue Data Structure