An inversion is an array of numbers is any pair (i,j) such
that i<j and A[i]>A[j]. What is the average number of
inversions in an array of n ?
distinct numbers?
Answers were Sorted based on User's Feedback
Answer / narina thakur
The average number of inversions in an array of N distinct
elements is N(N-1)/4
Proof:
Total number of inversions in a list L and its reverse Lr
is N(N-1)/2. Average list has half this amount, N(N-1)/4.
| Is This Answer Correct ? | 15 Yes | 6 No |
Answer / vivek sampara
How can you have the reverse of the list when it says i<j
and A[i]>A[j] ?
The Array always starts with A[0] till A[n] .
We cant have it reversed as A[n] to A[0].
The And the sequence of the total number of pairs are
n(n+1)/2
because the pairs are (n,n-1),(n,n-2),(n,n-3).....(n,0)
and (n-1,n-2),(n-1,n-3),(n-1,n-4)......,(n-1,0)
and (n-2,n-3),(n-2,n-4),(n-2,n-5)......,(n-2,0)
the list is n+(n-1)+(n-2)+.....3+2+1+0
reversing we'll get
1+2+3+4.....(n-1)+n =n(n+1)/2
So the average number of inversions are
(n(n+1)/2 )/n
= n(n+1)/2n
| Is This Answer Correct ? | 8 Yes | 8 No |
Describe an impedance matching circuit?
I have written some code of my project in java technology & some code in .net technology. Is it possible to integrate these into single project(module) to run complete project..?? if possible then how??
what should be the finish work of a carpenter per day
How will a tester be sure that He’s covered the entire functionality in his Test case and not missed out anything?
I am 2012 pass out b tech student(cse). i have recently started software manual testing class. Is this field is benefitial for me in future?
What is RIA course certification.? which is the best institute for ria courses in bangalore ?
what is memory interface????
how to find out the name of the users who are currently working starting with the same characters in unix os
difference between multi relational OLAP & multidimensional OLAP
computer is male or female.....???
Process-centered Methodologies , data-centered methodologies , object-oriented methodologies between differences
who is your role modal give in few sentances
Civil Engineering (5086)
Mechanical Engineering (4456)
Electrical Engineering (16639)
Electronics Communications (3918)
Chemical Engineering (1095)
Aeronautical Engineering (239)
Bio Engineering (96)
Metallurgy (361)
Industrial Engineering (259)
Instrumentation (3014)
Automobile Engineering (332)
Mechatronics Engineering (97)
Marine Engineering (124)
Power Plant Engineering (172)
Textile Engineering (575)
Production Engineering (25)
Satellite Systems Engineering (106)
Engineering AllOther (1379)