ProgrammingHard

A singly linked list is built by inserting 1, 2, 3 at the head. Then two nodes are popped from the head and their values printed. What is printed?

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

Correct answer: A. 3 2

Head insertion makes 3 the first node, then 2. Popping from the head removes 3 and then 2, so they print in that order.

More C Programming questions

Exams that ask this topic