Data Structures · Question 3 · Easy

Data Structures question 3

Starting with an empty queue: enqueue(A), enqueue(B), enqueue(C), dequeue(), enqueue(D), dequeue(). Which element is now at the front of the queue?

  1. C
  2. B
  3. D
  4. A
Answer and explanation

Answer: A. C

Explanation: Queue becomes A B C, then B C after the first dequeue, B C D after enqueue(D), and C D after the second dequeue. The front is C.

Previous: Starting with an empty stack, Kavya performs: push(5), push(8), push(3)… · Next: What is the time complexity of accessing the element at index i of an array?

Practise data structures

Try a fresh set of data structures questions with an explanation after every answer, free and without signing up: Data Structures practice. Or sit a full placement mock test.

More data structures questions

More technical & programming practice

Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems · Computer Networks · Software Engineering · Cloud & DevOps

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge