1.

What is the average number of inversions in an array of N distinct numbers?(a) N(N-1)/4(b) N(N+1)/2(c) N(N-1)/2(d) N(N-1)/3I got this question in my homework.I want to ask this question from Insertion sort topic in chapter Sorting of Data Structures & Algorithms II

Answer»

Right answer is (a) N(N-1)/4

Easiest explanation - The total number of PAIRS in a list L is N(N-1)/2. Thus, an average list has half this amount, or N(N-1)/4 inversions.



Discussion

No Comment Found

Related InterviewSolutions