Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a method using JAVA : public static ArrayList (lessthansymbol) Integer> me

ID: 3656242 • Letter: W

Question

write a method using JAVA : public static ArrayList (lessthansymbol) Integer> mergeSorted(ArrayList (lessthansymbol) Integer> a, ArrayList (lessthansymbol) Integer> 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 ex, 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

Explanation / Answer

public static ArrayList mergeSorted(ArrayList list1, ArrayList list2) { ArrayList mergeList = new ArrayList(list1.size() + list2.size()); int listIndex = 0; int left = 0; int right = 0; while(left