Search for question
Question

3. [10 points] Given an array of real numbers A[1...n], a pair of indices (i, j) is called an inversion if i < j and A[i] > A[j]. We want to count the total number of inver- sions in a given array. (i) Design a simple non-recursive algorithm to solve the problem. (ii) Design a simple recursive algorithm to solve the problem. COUNTINVERSIONS-NONRECURSIVE(A[1…..n]) COUNTINVERSIONS-RECURSIVE(A[1...n])

Fig: 1