Data Structures & AlgorithmsEasyTCS NQT · Wipro pattern

An empty queue performs: enqueue 7, enqueue 2, enqueue 9, dequeue, enqueue 4, dequeue. Which element is now at the front?

  1. A. 9
  2. B. 4
  3. C. 2
  4. D. 7

Correct answer: A. 9

FIFO: the two dequeues remove 7 and then 2 (the two oldest items). The queue is now 9, 4 with 9 at the front. '4' is the stack (LIFO) answer: the most recently added item.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic