1. The document describes the merge sort algorithm for sorting an array of integers in C code.
2. It works by recursively dividing the array into single element subarrays, and then merging the subarrays back together in a sorted order.
3. The key steps are recursively calling the mergesort function to divide the array, and calling the merge function to merge the divided subarrays back together in sorted order.
3. intmergesort(inta[], int low, int high) { 0,4 int mid; if(low<high) { mid=(low+high)/2;(2) mergesort(a,low,mid);(a,0,2) mergesort(a,mid+1,high); merge(a,low,high,mid); } return(0); } intmergesort(int a[], int low, int high) { 0,0 int mid; if(low<high)(0<0-false) { mid=(low+high)/2; mergesort(a,low,mid); mergesort(a,mid+1,high); merge(a,low,high,mid); } return(0);(now return will give control to Nearest function call) } intmergesort(int a[], int low, int high) { 0,2 int mid; if(low<high) { mid=(low+high)/2;(1) mergesort(a,low,mid);(0,1) mergesort(a,mid+1,high); merge(a,low,high,mid); } return(0); } intmergesort(int a[], int low, int high) { 0,1 int mid; if(low<high) { mid=(low+high)/2;(0) mergesort(a,low,mid);(0,0) mergesort(a,mid+1,high); merge(a,low,high,mid); } return(0); }
4. intmergesort(inta[], int low, int high) { 0,1 int mid; if(low<high) { mid=(low+high)/2;(0) mergesort(a,low,mid); mergesort(a,mid+1,high); merge(a,low,high,mid); } 0,1,0 return(0); } intmergesort(int a[], int low, int high) { 0,0 int mid; if(low<high)(0<0-false) { mid=(low+high)/2; mergesort(a,low,mid); mergesort(a,mid+1,high); merge(a,low,high,mid); } return(0); } intmergesort(int a[], int low, int high) { (1,1) int mid; if(low<high)(1<1-false) { mid=(low+high)/2; mergesort(a,low,mid); mergesort(a,mid+1,high); merge(a,low,high,mid); } return(0); } intmergesort(int a[], int low, int high) { 0,1 int mid; if(low<high) { mid=(low+high)/2;(0) mergesort(a,low,mid);(0,0) mergesort(a,mid+1,high);(0+1,1) merge(a,low,high,mid); } return(0); }
5. Until now array has been divided into 1 element each. Now array is merged and sorted in the merge function