(Solved):A C++ implementation for merge sort is as follows. int c[100]; //c[100] is a global array mergesort(int a[], int low, int high){ int mid; if (low < high) { mid=(low+high)/2; mergesort(a,low,m... View Answer...

 

Question

A C++ implementation for merge sort is as follows.

int c[100]; //c[100] is a global array

mergesort(int a, int low, int high){

int mid;

if (low < high) {

mid=(low+high)/2;

mergesort(a,low,mid);

mergesort(a,mid+1,high);

merge(a,low,high,mid);

}

return; }

void merge(int a, int low, int high, int mid){ int i, j, k;

i = low;

k = low;

j = mid + 1;

while (i <= mid && j <= high){ if (ai < aj){ ck = ai;

k++;

i++;

Scroll to top