ProgrammingVery hard

How many inversions does the array {2, 4, 1, 3, 5} contain?

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

Correct answer: A. 3

The inverted pairs are (2,1), (4,1) and (4,3). Merge sort counts exactly these during merges.

More C Programming questions

Exams that ask this topic