ProgrammingHard

A pointer-to-pointer loop deletes every node holding 2 from 2 -> 2 -> 3 -> 2 -> 1, using struct N **pp = &head and advancing only when no deletion happens. How many nodes remain?

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

Correct answer: C. 2

The three 2s are removed and the 3 and 1 stay. The pointer-to-pointer form needs no special case for the head node.

More C Programming questions

Exams that ask this topic