Question: Can you help me to debug this c++ file? The correct answer is shown in Expected, and my answer is shown in received For the

Can you help me to debug this c++ file? The correct answer is shown in "Expected", and my answer is shown in "received"

Can you help me to debug this c++ file? The correct answer

is shown in "Expected", and my answer is shown in "received" For

the test case 16, and 26, the number is {5 4 3

2 1 6 7 8 9 10}, so the inversion counter should

be 2 (5 exchange with 1, and 4 exchange with 2), not

6, but I receive 11. #include #include #include #include #include #include #include

using namespace std; // Function prototype static long mergesort (int array[], int

scratch[], int low, int high); Counts the number of inversions in an

array in theta(n 2) time. long count_inversions_slow(int array[], int length) // TODO

For the test case 16, and 26, the number is {5 4 3 2 1 6 7 8 9 10}, so the inversion counter should be 2 (5 exchange with 1, and 4 exchange with 2), not 6, but I receive 11.

#include #include #include #include #include #include #include using namespace std; // Function prototype static long mergesort (int array[], int scratch[], int low, int high); Counts the number of inversions in an array in theta(n 2) time. long count_inversions_slow(int array[], int length) // TODO int j, i, key; long int ans-0; // Use insertion sort for slow run for 2sj && array[i] > key){ array[i1]-array[i]; anstt array[i 1]key; return(ans); #include #include #include #include #include #include #include using namespace std; // Function prototype static long mergesort (int array[], int scratch[], int low, int high); Counts the number of inversions in an array in theta(n 2) time. long count_inversions_slow(int array[], int length) // TODO int j, i, key; long int ans-0; // Use insertion sort for slow run for 2sj && array[i] > key){ array[i1]-array[i]; anstt array[i 1]key; return(ans)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!