ProgrammingModerate

A histogram of sorted keys [1, 1, 2, 2, 2, 3] counts the adjacent equal pairs. How many such pairs are there?

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

Correct answer: A. 3

The pairs (1,1), (2,2) and (2,2) are adjacent and equal, giving 3.

More C Programming questions

Exams that ask this topic