PadhaikoAll subjects

Past exam question: 2078 Poush (Back), Q2(a)

Data Structure and Algorithms · 5 marks

Open in the Padhaiko app

Topic: Queues

Question

What is a queue? Explain circular queue as an ADT.

Solution

Definition of Queue: A queue is a linear data structure operating on the First-In, First-Out (FIFO) principle: insertions (enqueue) take place at the rear, and deletions (dequeue) take place at the front.

Circular Queue as an Abstract Data Type (ADT): A circular queue treats a fixed-capacity buffer Q[0..MAX-1] as a logical ring where index MAX - 1 wraps around to 0 via modulo arithmetic (index + 1) % MAX, eliminating false overflow in linear queues.

Answer:

A queue is a FIFO linear structure (enqueue at rear, dequeue at front). A circular queue ADT models a ring buffer using (index + 1) % MAX wrap-around with operations init, isEmpty, isFull ((rear+1)%MAX == front), enqueue, dequeue, and peek, achieving operations with full slot reuse.

All past exam questions for Data Structure and Algorithms