ProgrammingModerate

A queue is kept as a singly linked list with head and tail pointers. Enqueue 1, 2, 3, dequeue twice, enqueue 4, then dequeue once. Which value is returned by the last dequeue?

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

Correct answer: A. 3

The first two dequeues return 1 and 2. The last dequeue returns the oldest remaining value, which is 3.

More C Programming questions

Exams that ask this topic