Question: 1. Let A[0..n-1] be an array of n integer numbers. Assume that all the numbers are distinct. In the array, a pair of two numbers
1. Let A[0..n-1] be an array of n integer numbers. Assume that all the numbers are distinct. In the array, a pair of two numbers (A[i], A[j]) is called an inversion if i < j and A[i] > A[j].
(a) Assume that the array size is 3. What is the largest number of inversions possible in the array? Present a sample array with 3 integer values and describe your answer clearly.
(b) Similarly, answer the same question for an array with 5 integer values.
(c) Based on your answers to the question (a) and (b), what is the largest number of inversions in the general array with n elements?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
