Back to Practice Data Structures

Queues - Practice MCQs for CCAT

50 Questions Section B: Programming Data Structures

Queues Question Bank for C-CAT

Topic-wise Queues MCQs for CDAC C-CAT preparation with answers and explanations.

Q1.
Queue follows which principle?
ALIFO
BFIFO
CRandom
DPriority
Show Answer & Explanation

Correct Answer: B - FIFO

Queue follows FIFO - First In First Out principle.

Q2.
Enqueue and Dequeue operations take:
AO(n)
BO(1)
CO(log n)
DO(n²)
Show Answer & Explanation

Correct Answer: B - O(1)

Both enqueue and dequeue are O(1) operations.

Q3.
Which uses queue?
AFunction calls
BUndo
CCPU Scheduling
DRecursion
Show Answer & Explanation

Correct Answer: C - CPU Scheduling

CPU scheduling algorithms like Round Robin use queues.

Q4.
BFS traversal uses:
AStack
BPriority Queue
CQueue
DDeque
Show Answer & Explanation

Correct Answer: C - Queue

BFS uses queue to explore nodes level by level.

Q5.
In a circular queue, when rear reaches end:
AQueue is full
BError occurs
Crear wraps to front
DQueue resets
Show Answer & Explanation

Correct Answer: C - rear wraps to front

In circular queue, rear wraps around to beginning if space available.

Q6.
Priority queue differs from normal queue by:
ASize
BElements served by priority
CFIFO order
DSpeed
Show Answer & Explanation

Correct Answer: B - Elements served by priority

In priority queue, elements are served based on priority, not arrival order.

Q7.
Deque stands for:
ADelete queue
BDouble-ended queue
CDelayed queue
DDynamic queue
Show Answer & Explanation

Correct Answer: B - Double-ended queue

Deque is Double-ended queue allowing insertion/deletion at both ends.

Q8.
Which is NOT an application of queue?
APrint spooler
BKeyboard buffer
CProcess scheduling
DExpression evaluation
Show Answer & Explanation

Correct Answer: D - Expression evaluation

Expression evaluation uses stack, not queue.

Q9.
In array implementation of queue, problem of:
ABoth and space wastage
BUnderflow only
COverflow only
DNo problems
Show Answer & Explanation

Correct Answer: A - Both and space wastage

Array queue has overflow, underflow, and space wastage when elements are dequeued.

Q10.
Circular queue solves:
AOverflow
BUnderflow
CSpace wastage in linear queue
DAll problems
Show Answer & Explanation

Correct Answer: C - Space wastage in linear queue

Circular queue reuses empty spaces at the front, solving space wastage.

Q11.
In circular queue, condition for full queue is:
A(rear + 1) % size == front
Bfront == rear
Crear == size
Dfront == 0
Show Answer & Explanation

Correct Answer: A - (rear + 1) % size == front

Queue is full when the next position of rear equals front: (rear + 1) % size == front.

Q12.
Two queues can implement a:
ATree
BStack
CGraph
DHash table
Show Answer & Explanation

Correct Answer: B - Stack

Two queues can be used to implement a stack by transferring elements.

Q13.
Input-restricted deque allows:
ANo insertion
BDelete at one end only
CInsert and delete at both ends
DInsert at one end only
Show Answer & Explanation

Correct Answer: D - Insert at one end only

Input-restricted deque allows insertion at only one end but deletion at both ends.

Q14.
Output-restricted deque allows:
AInsert at both ends, delete at one
BDelete at one end only
CInsert at one end only
DNo deletion
Show Answer & Explanation

Correct Answer: A - Insert at both ends, delete at one

Output-restricted deque allows insertion at both ends but deletion at only one end.

Q15.
Priority queue is best implemented using:
AArray
BLinked list
CHeap
DStack
Show Answer & Explanation

Correct Answer: C - Heap

Heap provides O(log n) insert and O(log n) extract-min/max for priority queue.

Q16.
Sliding window maximum problem uses:
AStack
BSimple queue
CDeque
DPriority queue only
Show Answer & Explanation

Correct Answer: C - Deque

Deque (double-ended queue) efficiently solves sliding window maximum in O(n).

Q17.
In queue, if front == rear, the queue is:
AFull
BInvalid state
CHas one element
DEmpty
Show Answer & Explanation

Correct Answer: D - Empty

When front equals rear in most implementations, the queue is empty.

Q18.
First non-repeating character in stream uses:
AStack
BQueue with hash map
COnly array
DTree
Show Answer & Explanation

Correct Answer: B - Queue with hash map

Queue maintains order of characters while hash map tracks frequency.

Q19.
LRU cache can use queue because:
AFIFO tracks access order
BLIFO property
CRandom access
DFixed size
Show Answer & Explanation

Correct Answer: A - FIFO tracks access order

FIFO property helps track which element was accessed least recently.

Q20.
Josephus problem can be solved using:
AStack
BCircular queue
CBinary tree
DGraph
Show Answer & Explanation

Correct Answer: B - Circular queue

Circular queue models the circular arrangement of people in Josephus problem.

Q21.
Which principle does a queue follow?
ALIFO (Last In First Out)
BPriority-based
CFIFO (First In First Out)
DRandom access
Show Answer & Explanation

Correct Answer: C - FIFO (First In First Out)

A queue follows FIFO — the first element enqueued (added) is the first one to be dequeued (removed), similar to people waiting in a line.

Q22.
What are the two primary operations of a queue?
APush and Pop
BInsert and Delete
CEnqueue and Dequeue
DAdd and Remove
Show Answer & Explanation

Correct Answer: C - Enqueue and Dequeue

The standard queue operations are enqueue (adding an element to the rear) and dequeue (removing an element from the front).

Q23.
In a linear queue implemented using an array, what is the problem that arises after multiple enqueue and dequeue operations?
AWasted space at the front (cannot reuse freed positions)
BMemory leak
CStack overflow
DElements get sorted automatically
Show Answer & Explanation

Correct Answer: A - Wasted space at the front (cannot reuse freed positions)

In a linear queue, after dequeuing, the front moves forward, leaving unused space at the beginning of the array that cannot be reused, even if the rear reaches the end.

Q24.
How does a circular queue solve the problem of wasted space in a linear queue?
ABy using a linked list
BBy sorting elements
CBy wrapping around to the beginning of the array when the rear reaches the end
DBy doubling the array size
Show Answer & Explanation

Correct Answer: C - By wrapping around to the beginning of the array when the rear reaches the end

A circular queue uses modular arithmetic (rear = (rear + 1) % size) to wrap around to index 0 when the rear reaches the end of the array, reusing previously freed positions.

Q25.
In a circular queue of size n, the condition for the queue being full is:
Afront == rear
B(rear + 1) % n == front
Crear == n - 1
Dfront == 0 && rear == n - 1
Show Answer & Explanation

Correct Answer: B - (rear + 1) % n == front

In a circular queue, full condition is (rear + 1) % n == front. One position is deliberately left empty to distinguish between full and empty states.

Q26.
What is a deque (double-ended queue)?
AA queue with two fronts
BA queue where insertion and deletion can happen at both front and rear
CA queue that stores pairs of elements
DA stack with two tops
Show Answer & Explanation

Correct Answer: B - A queue where insertion and deletion can happen at both front and rear

A deque allows insertion and deletion at both the front and rear ends. It combines the functionality of both stacks and queues.

Q27.
In a priority queue, elements are dequeued based on:
AArrival order (FIFO)
BLast arrival (LIFO)
CRandom selection
DPriority value
Show Answer & Explanation

Correct Answer: D - Priority value

In a priority queue, each element has an associated priority. Elements with higher (or lower, depending on implementation) priority are dequeued before elements with lower priority.

Q28.
Which data structure is most commonly used to efficiently implement a priority queue?
AArray
BHeap
CLinked list
DStack
Show Answer & Explanation

Correct Answer: B - Heap

A binary heap provides O(log n) insertion and O(log n) deletion of the highest-priority element, making it the most efficient common implementation for priority queues.

Q29.
What is the time complexity of enqueue and dequeue operations in a queue implemented using a linked list?
AO(n) each
BO(1) each
CO(log n) each
DO(1) for enqueue, O(n) for dequeue
Show Answer & Explanation

Correct Answer: B - O(1) each

Using a linked list with both head (front) and tail (rear) pointers, enqueue (insert at tail) and dequeue (remove from head) are both O(1) operations.

Q30.
Which of the following is a valid application of a queue?
ABFS (Breadth-First Search) of a graph
BUndo operations
CFunction call management
DExpression evaluation
Show Answer & Explanation

Correct Answer: A - BFS (Breadth-First Search) of a graph

BFS uses a queue to explore nodes level by level. The current node's neighbors are enqueued and processed in FIFO order. Function calls, undo, and expression evaluation typically use stacks.

Q31.
In a circular queue of size 5 with front = 2 and rear = 4, how many elements are in the queue?
A5
B3
C4
D2
Show Answer & Explanation

Correct Answer: D - 2

Number of elements = (rear - front + size) % size = (4 - 2 + 5) % 5 = 7 % 5 = 2. The elements are at indices 2 and 3.

Q32.
What is the condition for a circular queue being empty?
Afront == rear
Bfront == -1 && rear == -1
CBoth A and B are used in different implementations
Drear == front - 1
Show Answer & Explanation

Correct Answer: C - Both A and B are used in different implementations

Different implementations use different conventions. Some use front == rear to indicate empty, while others initialize both to -1 and check that condition. Both are valid approaches.

Q33.
An input-restricted deque allows:
AInsertion at both ends, deletion only at the front
BInsertion only at the rear, deletion at both ends
CInsertion and deletion only at the front
DInsertion and deletion only at the rear
Show Answer & Explanation

Correct Answer: B - Insertion only at the rear, deletion at both ends

An input-restricted deque restricts insertion to one end (rear) but allows deletion from both the front and rear ends.

Q34.
An output-restricted deque allows:
AInsertion at both ends, deletion only at the front
BInsertion only at the rear, deletion at both ends
CInsertion and deletion only at the front
DDeletion at both ends, insertion only at the front
Show Answer & Explanation

Correct Answer: A - Insertion at both ends, deletion only at the front

An output-restricted deque allows insertion at both front and rear, but restricts deletion to only the front end.

Q35.
CPU process scheduling commonly uses which type of queue?
ASimple queue
BCircular queue
CDeque
DPriority queue
Show Answer & Explanation

Correct Answer: D - Priority queue

CPU scheduling algorithms like Priority Scheduling use priority queues where processes with higher priority are scheduled before those with lower priority.

Q36.
What is the time complexity of inserting an element in a priority queue implemented using an unsorted array?
AO(1)
BO(n)
CO(log n)
DO(n²)
Show Answer & Explanation

Correct Answer: A - O(1)

In an unsorted array implementation, insertion is O(1) — we simply add the element at the end. However, dequeue (removing the highest priority) requires O(n) to find it.

Q37.
What is the time complexity of dequeue in a priority queue implemented using a sorted array?
AO(log n)
BO(n)
CO(1)
DO(n²)
Show Answer & Explanation

Correct Answer: C - O(1)

In a sorted array implementation, the highest-priority element is always at a known position (front or rear), so dequeue is O(1). However, insertion requires O(n) to maintain the sorted order.

Q38.
Queues are used in which of the following scenarios?
APrint job scheduling
BKeyboard buffer for keystrokes
CHandling requests in a web server
DAll of the above
Show Answer & Explanation

Correct Answer: D - All of the above

Queues handle scenarios where requests must be processed in order of arrival: print jobs wait in a queue, keystrokes are buffered in order, and web server requests are queued for processing.

Q39.
A multilevel queue scheduling uses:
AMultiple queues, each with its own scheduling algorithm
BA single queue with varying priorities
CA stack for each priority level
DA single sorted array
Show Answer & Explanation

Correct Answer: A - Multiple queues, each with its own scheduling algorithm

Multilevel queue scheduling partitions processes into groups, each with its own queue and scheduling algorithm (e.g., foreground processes use round-robin, background uses FCFS).

Q40.
What is the maximum number of elements a circular queue of size n can hold?
An
B2n
Cn + 1
Dn - 1
Show Answer & Explanation

Correct Answer: D - n - 1

A circular queue of size n can hold at most n - 1 elements. One position is kept empty to distinguish between the full and empty conditions.

Q41.
In a queue implemented using two stacks (S1 for enqueue, S2 for dequeue), what is the amortized time complexity of dequeue?
AO(n)
BO(n²)
CO(log n)
DO(1)
Show Answer & Explanation

Correct Answer: D - O(1)

Although a single dequeue might take O(n) when S2 is empty (transferring all elements from S1), each element is transferred at most once. Over n operations, the amortized cost per dequeue is O(1).

Q42.
Level-order traversal of a binary tree uses which data structure?
AQueue
BStack
CPriority queue
DDeque
Show Answer & Explanation

Correct Answer: A - Queue

Level-order (BFS) traversal processes nodes level by level. A queue ensures that nodes at the current level are processed before their children (next level).

Q43.
In a circular queue, the formula to calculate the next position of rear is:
Arear = rear + 1
Brear = (rear - 1 + size) % size
Crear = rear % size
Drear = (rear + 1) % size
Show Answer & Explanation

Correct Answer: D - rear = (rear + 1) % size

rear = (rear + 1) % size wraps the rear index around to 0 when it reaches the end of the array, implementing the circular behavior.

Q44.
Which queue variant is best suited for a sliding window maximum problem?
ADeque
BPriority queue
CSimple queue
DCircular queue
Show Answer & Explanation

Correct Answer: A - Deque

A deque (specifically a monotonic deque) efficiently solves the sliding window maximum in O(n). Elements are added/removed from both ends to maintain the window and the maximum property.

Q45.
What is the time complexity of BFS traversal of a graph with V vertices and E edges using a queue?
AO(V + E)
BO(E)
CO(V)
DO(V × E)
Show Answer & Explanation

Correct Answer: A - O(V + E)

BFS visits each vertex once (O(V)) and explores each edge once (O(E)). The queue operations (enqueue and dequeue) are O(1) each, giving total time O(V + E).

Q46.
A queue where both enqueue and dequeue happen at the same end behaves like a:
APriority queue
BDeque
CStack
DCircular queue
Show Answer & Explanation

Correct Answer: C - Stack

If both insertion and deletion happen at the same end, the last element inserted is the first to be deleted — this is exactly LIFO behavior, which is a stack.

Q47.
In a max-priority queue, the dequeue operation always removes:
AThe smallest element
BA random element
CThe oldest element
DThe largest element
Show Answer & Explanation

Correct Answer: D - The largest element

A max-priority queue always removes the element with the highest priority (largest value). A min-priority queue would remove the smallest element.

Q48.
Which of the following is true about a queue implemented using a singly linked list with only a head pointer?
AEnqueue is O(n), dequeue is O(1)
BBoth enqueue and dequeue are O(1)
CEnqueue is O(1), dequeue is O(n)
DBoth are O(n)
Show Answer & Explanation

Correct Answer: A - Enqueue is O(n), dequeue is O(1)

With only a head pointer, dequeue (remove from head) is O(1). But enqueue (insert at the tail) requires traversing the entire list to reach the end, taking O(n).

Q49.
A circular buffer (ring buffer) is an implementation of which data structure?
AStack
BCircular queue
CBinary tree
DHash table
Show Answer & Explanation

Correct Answer: B - Circular queue

A circular buffer uses a fixed-size array with wrap-around semantics, implementing a circular queue. It's commonly used in producer-consumer scenarios and I/O buffering.

Q50.
What is the time complexity of inserting an element into a min-heap-based priority queue?
AO(1)
BO(n)
CO(n log n)
DO(log n)
Show Answer & Explanation

Correct Answer: D - O(log n)

In a heap-based priority queue, the new element is added at the end and then percolated up (heapify up) to maintain the heap property. The maximum number of swaps is the height of the heap, which is O(log n).

Showing 1-10 of 50 questions