+1 vote
in Data Structures & Algorithms II by (110k points)
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)/3

I got this question in my homework.

I want to ask this question from Insertion sort topic in chapter Sorting of Data Structures & Algorithms II

1 Answer

+1 vote
by (614k points)
selected by
 
Best 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.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...