(Solved) : 4 Let 01 22 Array Numbers Let S Define Reverse Pair Distinct Indices J E 1 2 N Aj E Di O Q43999680 . . .

4. Let A = (01, 22, …, an be an array of numbers. Let’s define a ‘reverse’ as a pair of distinct indices i, j e {1,2,…,n} such that i<j but a; > 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. (a) Let A be an arbitrary array of length n. At most, how many reverses can A con- tain in terms of the array size n? Explain your answer with a short statement. Show transcribed image text 4. Let A = (01, 22, …, an be an array of numbers. Let’s define a ‘reverse’ as a pair of distinct indices i, j e {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. (a) Let A be an arbitrary array of length n. At most, how many reverses can A con- tain in terms of the array size n? Explain your answer with a short statement.
Expert Answer
Answer to 4. Let A = (01, 22, …, an be an array of numbers. Let’s define a ‘reverse’ as a pair of distinct indices i, j e {1,2,….
OR