May 042017

Given two sorted arrays of size m and n respectively. Also given an empty third array of size (m+n). write code to merge the two arrays and store the result in the third array.

          a = {1, 4, 5, 9}
          b = {0, 2, 3, 7, 15, 29}
          c = {0, 1, 2, 3, 4, 5, 7, 9, 15, 29}

Continue reading »

Jun 282012

There are 2 sorted arrays of size m and m+n respectively. First array (of size m) has m elements and Second array (of size m+n) has only n elements (last m positions are blank). So, the total number of elements in both the arrays is m+n (m in first and n in second). Write code to merge the m+n elements in the 2nd array such that the result is sorted.

If the two arrays are as below:

Then the output should be:

Continue reading »