---
title: "Circular queue vs linear queue"
subject: "Data Structure and Algorithm"
chapter: 2
key: "semester_4/data_structure_and_algorithm:circular-vs-linear-queue"
source: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/circular-vs-linear-queue
site: BCT Engineering
---

# Circular queue vs linear queue

Data Structure and Algorithm · Chapter 2: The Stack and Queue

- Asked in: 2073 Bhadra, 5 marks
- Video: [Linear and circular queue difference - Data structures lecture series](https://www.youtube.com/watch?v=-VzzjEBhbEk) — Eezytutorials CSE & Kids channel
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/circular-vs-linear-queue
- Whole chapter: https://www.bctengineer.com/md/semester_4/data_structure_and_algorithm/chapter-2

## Question

Explain how a circular queue differs from a linear queue with suitable example.

## Short answer

Linear queue does not reuse freed front cells; circular queue wraps rear modulo N. Example: N=5, insert 10,20,30,40,50, delete two, insert 60 — linear overflows despite free space; circular succeeds, rear wraps to 0.

## Answer

A **linear queue** uses an array in a straight line: `rear` only moves forward and positions before `front` are never reused. A **circular queue** joins the last position to the first, so indices wrap around with `(index + 1) % N`.

| Linear queue | Circular queue |
|---|---|
| `rear` increases up to N − 1 and stops | `rear` wraps to 0 using `(rear + 1) % N` |
| Freed cells at the front are not reused | Freed cells are reused |
| Full test: `rear == N - 1` | Full test: `(rear + 1) % N == front` |
| Empty test: `front > rear` | Empty test: `front == -1` |
| Can report overflow even when cells are free | Overflows only when all cells are used |
| Simple to implement | Slightly more complex |
| Poor memory use | Better memory use |

#### Example (N = 5): insert 10, 20, 30, 40, 50, delete two, insert 60

**Linear queue**

| Operation | Array contents (index 0 → N-1) | front | rear |
|---|---|---|---|
| enqueue(10) | 10 _ _ _ _ | 0 | 0 |
| enqueue(20) | 10 20 _ _ _ | 0 | 1 |
| enqueue(30) | 10 20 30 _ _ | 0 | 2 |
| enqueue(40) | 10 20 30 40 _ | 0 | 3 |
| enqueue(50) | 10 20 30 40 50 | 0 | 4 |
| dequeue() returns 10 | _ 20 30 40 50 | 1 | 4 |
| dequeue() returns 20 | _ _ 30 40 50 | 2 | 4 |
| enqueue(60): rear = 4 → Queue overflow | _ _ 30 40 50 | 2 | 4 |

Two cells are free, yet `enqueue(60)` fails.

**Circular queue**

| Operation | Array contents (index 0 → N-1) | front | rear |
|---|---|---|---|
| enqueue(10) | 10 _ _ _ _ | 0 | 0 |
| enqueue(20) | 10 20 _ _ _ | 0 | 1 |
| enqueue(30) | 10 20 30 _ _ | 0 | 2 |
| enqueue(40) | 10 20 30 40 _ | 0 | 3 |
| enqueue(50) | 10 20 30 40 50 | 0 | 4 |
| dequeue() returns 10 | _ 20 30 40 50 | 1 | 4 |
| dequeue() returns 20 | _ _ 30 40 50 | 2 | 4 |
| enqueue(60) | 60 _ 30 40 50 | 2 | 0 |

Here `rear` wraps to index 0 and 60 is stored.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. The full test for a circular queue is:
   A. (rear + 1) % N == front
   B. rear == N - 1
   C. front > rear
   D. front == -1
   Answer: A. A linear queue uses rear == N - 1. (Key point: Full test)

2. Why can a linear queue report overflow with free cells?
   A. Cells before front are never reused as rear stops at N - 1
   B. It wraps rear to 0
   C. It uses linked nodes
   D. front is always 0
   Answer: A. A circular queue wraps indices and reuses them. (Key point: Reuse of cells)

3. N=5: insert 10-50, delete two, then enqueue(60). Linear queue gives:
   A. 60 stored at index 0
   B. 60 stored at index 2
   C. Queue overflow
   D. front reset to 0
   Answer: C. rear = 4 = N - 1, though two cells are free. (Key point: Example)

4. Which empty test belongs to the circular queue?
   A. front > rear
   B. rear == 0
   C. (rear+1)%N == front
   D. front == -1
   Answer: D. Linear queue uses front > rear. (Key point: Empty test)

## Related in Data Structure and Algorithm

- [Linear and circular queue operations](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Alinear-circular-queue-algorithms) — Data Structure and Algorithm, chapter 2
- [Enqueue and dequeue in circular queue](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Acircular-queue-insert-delete) — Data Structure and Algorithm, chapter 2, asked 2×
- [Circular queue with display operation](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Acircular-queue-enqueue-dequeue-display) — Data Structure and Algorithm, chapter 2
- [Circular queue algorithm with conditions](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Acircular-queue-algorithm-conditions) — Data Structure and Algorithm, chapter 2
- [Circular queue using linked list](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Acircular-queue-linked-list) — Data Structure and Algorithm, chapter 4
- [Linear queue using array](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Alinear-queue-array-implementation) — Data Structure and Algorithm, chapter 2, asked 2×

## Related in other subjects

- [Linear convolution via circular convolution](https://www.bctengineer.com/question.md?key=semester_7%2Fdigital_signal_analysis_and_processing%3Alinear-conv-via-circular) — Digital Signal Analysis and Processing, chapter 7
- [Double refraction, linear and circular light](https://www.bctengineer.com/question.md?key=semester_1%2Fengineering_physics%3Adouble-refraction-produce-polarized-light) — Engineering Physics, chapter 4
- [TE vs TM mode in circular waveguide](https://www.bctengineer.com/question.md?key=semester_7%2Frf_and_microwave_engineering%3Acircular-waveguide-te-vs-tm) — RF and Microwave Engineering, chapter 4
- [Angular vs linear precision in traversing](https://www.bctengineer.com/question.md?key=semester_4%2Fsurveying_ii%3Atraverse-angular-linear-precision-relation) — Surveying II, chapter 1, asked 2×
