Suppose you have two arrays of ints, arr1 and arr2, each containing ints that are sorted in ascending order. Write a static method named merge that receives these two arrays as parameters and returns a reference to a new, sorted array of ints that is the result of merging the contents of the two arrays, arr1 and arr2. Note: you do not need to (and should not)sort here. Think of having two sorted piles of cards, that you’re combining (merging) into another pile. You keep putting cards into the new pile, sometimes taking from one of your original piles, sometimes taking from the other.

LANGUAGE: JAVA

CHALLENGE:

Suppose you have two arrays of ints, arr1 and arr2, each containing ints that are sorted in ascending order.

Write a static method named merge that receives these two arrays as parameters and returns a reference to a new, sorted array of ints that is the result of merging the contents of the two arrays, arr1 and arr2.

Note: you do not need to (and should not)sort here. Think of having two sorted piles of cards, that you’re combining (merging) into another pile. You keep putting cards into the new pile, sometimes taking from one of your original piles, sometimes taking from the other.

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,