HW2/testcase/problem2/tester.cpp
/* l is for left index and r is right index of the 
   sub-array of arr to be sorted */
l is for left index and r is right index of the
sub-array of arr to be sorted
l is for left index and r is right index of the sub - array of arr to be sorted
void mergeSort(int arr[], int l, int r) { 
	k++;
	int st = 0;
	for (int i = l; i < r; ++i)
	{
		if(arr[i] > arr[i + 1]){
			st = 1;
			break;
		}
	}
	if(st == 0)
		return;
    if (l < r){
        int m = 0;
        if( (l + r) % 2 == 0)
        	m = l+(r-l)/2 - 1;
        else
        	m = l+(r-l)/2;
        mergeSort(arr, l, m); 
        mergeSort(arr, m+1, r); 
        merge(arr, l, m, r); 
    } 
}
void mergeSort ( int arr [ ] , int l , int r ) { k ++ ; int st = 0 ; for ( int i = l ; i < r ; ++ i ) { if ( arr [ i ] > arr [ i + 1 ] ) { st = 1 ; break ; } } if ( st == 0 ) return ; if ( l < r ) { int m = 0 ; if ( ( l + r ) % 2 == 0 ) m = l + ( r - l ) / 2 - 1 ; else m = l + ( r - l ) / 2 ; mergeSort ( arr , l , m ) ; mergeSort ( arr , m + 1 , r ) ; merge ( arr , l , m , r ) ; } }
l is for left index and r is right index of the
sub-array of arr to be sorted
l is for left index and r is right index of the sub - array of arr to be sorted
// Same as (l+r)/2, but avoids overflow for  // large l and h  // Sort first and second halves 