C++/C++ Programming
Expert: vijayan - 11/24/2008
Questiontwo one-dimensional arrays A and B which are stored in assending order.to merge them into a single sorted array C that contains every item from arrays A and B, in ascending order,
Answerhere is a simple non-recursive pseudocode implementation to merge two arrays a, b into array result:
function merge( array a, array b, array result )
make result an empty array
initialize int i, j to 0
while (i < length(a)) and (j < length(b))
if a[i] < b[j]
append a[i] to result
increment i
else
append b[j] to result
increment j
while i < length(a)
append a[i] to result
increment i
while j < length(b)
append b[j] to result
increment j