Question: a . The five inversions of the array [ 2 , 3 , 8 , 6 , 1 ] are: ( 2 , 1 )

a. The five inversions of the array [2,3,8,6,1] are: (2,1),(3,1),(8,1),(8,6),(6,1).
b. The array with elements from the set {1,2,..., n} that has the most inversions is the array sorted in descending order. It has n(n-1)/2 inversions.
c. The running time of insertion sort is proportional to the number of inversions in the input array. This is because each inversion corresponds to a pair of elements that are out of order and need to be swapped, and each swap takes constant time.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!