ITEC 136 Homework 9



ITEC 136 Homework 9         
Write a function merge that take two sorted arrays as parameters. The function should create a new array whose size is the sum of the two parameter array lengths.  The merge function should then fill in the new array with elements from the two parameters such that the two sorted arrays are merged into one sorted array.  Here are the detailed specifications:
The two parameter arrays should not be changed as a result of calling the function.  This is a good practice overall.
You may not simply append the two arrays and then sort the result.  Instead, you should be examining each element of the arrays in turn to see which one is smaller.
Return a newly created array with the proper contents.
The time to execute your algorithm should be directly proportional to sum of the number of elements in both input arrays.
See the example below for how the function should be called: