Question: Write a function merge(a, b) that takes two arrays a and b of integers, each in sorted (nondecreasing) order, and returns a new array that

Write a function merge(a, b) that takes two arrays a and b of integers, each in sorted (nondecreasing) order, and returns a new array that combines the elements of a and b in sorted order. The function should not modify a or b. IN RUBY

>> a = [1, 2, 3, 6, 9]

=> [1, 2, 3, 6, 9]

>> b = [2, 3, 5, 7] => [2, 3, 5, 7]

>> merge(a, b) => [1, 2, 2, 3, 3, 5, 6, 7, 9]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!