Suppose that we run the merge algorithm on two sorted lists, one of length 10 and the other of length 20. a. What is the number of comparisons it uses in the best case? b. What is the number of comparisons it uses in the worst case? code example

Example: Write a function that takes in two sorted arrays and returns a new array with all elements sorted not using array method sort.

// const newSortArrays = (arr1, arr2) => {
//     let output = [];
//     while (arr1.length && arr2.length) {
//        if (arr1[0] < arr2[0]) 
//         output.push(arr1[0] < arr2[0] ? arr1.shift() : arr2.shift())
//     }
//     return [...output, ...arr1, ...arr2]
// }