Back In the print window choose "Save as PDF" as the destination
NOTE.CS

Queue

1 topic ยท 28 Nov 2026
1

Queue

Data Structure

A queue is FIFO (First In, First Out): insert at the rear (enqueue), remove from the front (dequeue).

  • Circular queue โ€” reuses empty slots at the start: rear = (rear + 1) % size.
  • Deque โ€” insert/remove at both ends.
  • Priority queue โ€” highest priority leaves first (usually a heap).

Uses: CPU scheduling, printer queue, BFS, buffering.

C++
queue<int> q;
q.push(10); q.push(20); q.push(30);
cout << q.front();   // 10
q.pop();             // removes 10
cout << q.size();    // 2