Question: Please use C++ Text Code start here: #include #include #include #include #include #include #include using namespace std; // Function prototype. static long mergesort(int array[], int
Please use C++

![#include #include using namespace std; // Function prototype. static long mergesort(int array[],](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f2f2f396fb7_93966f2f2f32f2b1.jpg)
Text Code start here:
#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 }
/** * Counts the number of inversions in an array in theta(n lg n) time. */ long count_inversions_fast(int array[], int length) { // TODO // Hint: Use mergesort! }
static long mergesort(int array[], int scratch[], int low, int high) { // TODO }
int main(int argc, char *argv[]) { // TODO: parse command-line argument
cout
istringstream iss; int value, index = 0; vector values; string str; str.reserve(11); char c; while (true) { c = getchar(); const bool eoln = c == ' ' || c == ' '; if (isspace(c) || eoln) { if (str.length() > 0) { iss.str(str); if (iss >> value) { values.push_back(value); } else { cerr
// TODO: produce output
return 0; }
Grah version for code:
![int scratch[], int low, int high); /** * Counts the number of](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f2f2f435258_93966f2f2f3d6179.jpg)
![inversions in an array in theta(n^2) time. */ long count_inversions_slow(int array[], int](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f2f2f4cc366_94066f2f2f469c38.jpg)
1. Objective Your goal is to write a program that will enable you to make use of mergesort to solve a seemingly unrelated problem. [This is a common interview question. I too have been asked this one!] 1. Objective Your goal is to write a program that will enable you to make use of mergesort to solve a seemingly unrelated problem. [This is a common interview question. I too have been asked this one!]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
