(Solved) : 4 Let 22 Array Numbers Let S Define Reverse Pair Distinct Indices J 1 2 N Aj E Di Order Q43999697 . . .
![4. Let A = [a], 22, ..., an be an array of numbers. Lets define a reverse as a pair of distinct indices i, j € {1,2,...,n}](https://media.cheggcdn.com/media/0e5/0e50b455-cbe4-47e7-b4b5-560f8fd9a79d/phpp4oogk.png)

4. Let A = [a], 22, …, an be an array of numbers. Let’s define a ‘reverse’ as a pair of distinct indices i, j € {1,2,…,n} such that i<j but di > aj; i.e., di and a; are out of order. For example – In the array A = (1, 3, 5, 2, 4, 6), (3, 2), (5, 2) and (5, 4) are the only reverses i.e. the total number of reverses is 3. (c) Your algorithm has an inner loop and an outer loop. Provide the “useful” loop invariant (LI) for the inner loop. You don’t need to show the complete LI proof. Show transcribed image text 4. Let A = [a], 22, …, an be an array of numbers. Let’s define a ‘reverse’ as a pair of distinct indices i, j € {1,2,…,n} such that i aj; i.e., di and a; are out of order. For example – In the array A = (1, 3, 5, 2, 4, 6), (3, 2), (5, 2) and (5, 4) are the only reverses i.e. the total number of reverses is 3.
(c) Your algorithm has an inner loop and an outer loop. Provide the “useful” loop invariant (LI) for the inner loop. You don’t need to show the complete LI proof.
Expert Answer
Answer to 4. Let A = [a], 22, …, an be an array of numbers. Let’s define a ‘reverse’ as a pair of distinct indices i, j € {1,2…
OR