ProgrammingModerate

After removing duplicate keys from a sorted array of records with the two-index method (keep a[w] when its key differs from the last kept key), how many records remain for keys 2, 2, 5, 5, 5, 9?

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

Correct answer: D. 3

The distinct keys are 2, 5 and 9, so three records remain after the two-index pass.

More C Programming questions

Exams that ask this topic