Question: Write a method public static ArrayList mergeSorted(ArrayList a, ArrayList b) that merges two sorted array lists, producing a new sorted array list. Keep an index

Write a method

public static ArrayList mergeSorted(ArrayList a,
ArrayList b)

that merges two sorted array lists, producing a new sorted array list. Keep an index into each array list, indicating how much of it has been processed already. Each time, append the smallest unprocessed element from either array list, then advance the index. For example, if a is 1 4 9 16 and b is 4 7 9 9 11 then mergeSorted returns the array list     1 4 4 7 9 9 9 11 16

Step by Step Solution

3.32 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Program screenshots Sample output Code to copy import the necessary package import javautilAr... View full answer

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 Java Concepts Late Objects Questions!