Question: 2 . ( 5 0 ) [ Counting inversion: algorithm tracing ] Consider the counting inversion algorithm Sort - andCount studied in class and shown
Counting inversion: algorithm tracing Consider the counting inversion algorithm SortandCount studied in class and shown below.
SortandCountL
if list L has one element
return and the list L
Divide the list into two halves A and B
r A
mp@subsuprtextrmBBmathrm Bleftarrowmathrm SortandCount B
mp@subsuprABLleftarrowmathrm MergeandCountA B
return r r A r B r
Run this algorithm against the input file shown below, and a show the recursion tree during the divide phase and the conquer & combine phase, respectively, and b show each returned result as the pair of the inversion count and the sorted result eg exactly in the order of execution. If the input array has an odd number of elments, the left half contains one fewer element than the right half. See the example recursion trees below.
Input file:
Example recursion tree for an input file
Divide
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
