Question:

Which of the following elements will be present in a queue after the end of the following operation sequence? Assume the queue is empty initially.
enqueue(10)
enqueue(20)
enqueue(30)
dequeue()
enqueue(40)
dequeue()
enqueue(50)
enqueue(60)
(A) 60
(B) 30
(C) 20
(D) 50
Choose the correct answer from the options given below:

Show Hint

Remember FIFO: The element that enters the queue first will always be removed first by dequeue().
Trace front deletions carefully to identify which elements remain.
Updated On: Sep 7, 2026
  • (A), (B) and (D) only
  • (A), (B) and (C) only
  • (A), (B), (C) and (D)
  • (B), (C) and (D) only
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

Concept:
A queue operates on the First-In-First-Out (FIFO) principle.
The enqueue operation inserts an element at the rear of the queue, while the dequeue operation removes the element that has been in the queue the longest from the front.

Step 1: Tracing Queue State Changes:

Let the queue be represented as a list where the front is on the left and the rear is on the right:
1. enqueue(10): $[10]$
2. enqueue(20): $[10, 20]$
3. enqueue(30): $[10, 20, 30]$
4. dequeue(): The front element 10 is removed. Queue: $[20, 30]$
5. enqueue(40): $[20, 30, 40]$
6. dequeue(): The front element 20 is removed. Queue: $[30, 40]$
7. enqueue(50): $[30, 40, 50]$
8. enqueue(60): $[30, 40, 50, 60]$

Step 2: Checking the Final Queue Elements:

The remaining elements in the queue are $30, 40, 50, 60$.
Matching these against the options provided:
- 60 is present $\rightarrow$ (A)
- 30 is present $\rightarrow$ (B)
- 20 is NOT present (it was dequeued in step 6)
- 50 is present $\rightarrow$ (D)
Thus, the items from the list that remain in the queue are (A), (B), and (D).
Final Answer:
The elements present are (A), (B) and (D) only, which corresponds to option (A).
Was this answer helpful?
0
0