Question discussion

How many inversions (pairs i < j with a[i] > a[j]) does the array 8, 4, 2, 1, 9, 3, 7 contain?

947Medium DSSSB TGT Computer Science 0 replies 1 views
0

How many inversions (pairs i < j with a[i] > a[j]) does the array 8, 4, 2, 1, 9, 3, 7 contain?

  • A9
  • B10
  • C13
  • D11
Correct answer: D

Explanation

Counting greater elements to the right: 8→5 (4,2,1,3,7), 4→3 (2,1,3), 2→1 (1), 9→2 (3,7) = 11.

Discussion 0

Nobody has replied yet. Start the discussion!