Question: Let [1. . ] be an array of distinct numbers (i.e., no two numbers are equal). If < and [] > [], then the pair
Let [1. . ] be an array of distinct numbers (i.e., no two numbers are equal). If < and [] > [], then the pair ([], []) is called an inversion of .
[5a]. List all inversions of the array {4, 2, 9, 1, 7}. (2.5 points)
[5b]. What array with elements from the set {1, 2, . . . , } has the most inversions? How many inversions does it have? (2.5 points)
[5c]. Give a divide-and-conquer algorithm that computes the number of inversions in array in ( log ) time. Show that your algorithm takes ( log ). (Hint: Modify merge sort.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
