We are given a sequence of n numbers < a1 , a2 , . . . , an > which we assume are all distinct, and we define an inversion to be a pair i < j such that ai > aj . it is generally assumed that the number of inversions in a sequence is a good measure of how far the sequence is from the sorted sequence. however, one might feel that this measure is too sensitive. let us call a pair a significant inversion if i < j and ai > 2aj . give an o(n log n) algorithm to count the number of significant inversions in a sequence
Answers
Answered by
0
a>n if ai>AJ will same
Similar questions