int merge(int M[], int N[], int m, int n)

{

int k = m + n - 1;

m--, n--;

while(n >= 0 && m >= 0)

M[k--] = M[m] > N[n] ? M[m--] : N[n--];

while(n >= 0)

M[k--] = N[n--];

}

Advertisements

int merge(int M[], int N[], int m, int n)

{

int k = m + n - 1;

m--, n--;

while(n >= 0 && m >= 0)

M[k--] = M[m] > N[n] ? M[m--] : N[n--];

while(n >= 0)

M[k--] = N[n--];

}

Advertisements

%d bloggers like this:

Hi,Can you please check for below arrays I was not getting O/P as required int[] mPlusN = new int[9] { 2, 8, 0, 0, 0, 13, 0, 15, 20 }; int[] N = { 5, 7, 9, 25 };