Feb. 21, 2014, 4:22 p.m. by Rosalind Team
Topics: Sorting
The merging procedure is an essential part of “Merge Sort” (which is considered in one of the next problems).
Given: A positive integer
Return: A sorted array
4 2 4 10 18 3 -5 11 12
-5 2 4 10 11 12 18
Hint
The very first element of
$C$ is either$A[1]$ or$B[1]$ , whichever is smaller. The rest of$C$ can then be constructed recursively.Source: Algorithms by Dasgupta, Papadimitriou, Vazirani. McGraw-Hill. 2006.