Sequence the complete process of enqueue operation in a queue:
(A) Add the element to the rear of the queue.
(B) Check if the queue is full.
(C) Increment the rear pointer.
(D) Return success message.
Sequence the complete process of enqueue operation in a queue:
(A) Add the element to the rear of the queue.
(B) Check if the queue is full.
(C) Increment the rear pointer.
(D) Return success message.
Solution
Check if the queue is full (B)
Add the element to the rear of the queue (A)
Increment the rear pointer (C)
Return success message (D)
The full check must come first, because adding to a full queue causes overflow. The success message comes last, after the insertion is complete.
Options 1 and 2: they add the element before checking whether the queue is full, which risks overflow.
Option 4: it increments the rear pointer before checking for space, and returns success before the element is added.
Related questions:
2026: 23 May Shift 1
2026: 29 May Shift 2
2026: 26 May Shift 1