1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

void merge(int A[], int m, int B[], int n) 
{
	int k = m+n-1;
	m--, n--;
	while(m >= 0 && n >= 0)
	{
		if (A[m] > B[n])
			A[k--] = A[m--];
		else
			A[k--] = B[n--];
	}

	//while(m >= 0)A[k--] = A[m--]; //this line is redundant
	while(n >= 0)A[k--] = B[n--];
}
View Program Text


Test Status