Question: (Keep this JAVA program as simple as possible, and it will be great if you add comments too!) Thanks! JAVA Program Merge Two Sorted Lists:

(Keep this JAVA program as simple as possible, and it will be great if you add comments too!) Thanks!

JAVA Program Merge Two Sorted Lists: Write a method that merges two sorted lists of integers into a new sorted list:

public static int[] merge(int[] list1, int[] list2)

Implement the method in a way that takes at most list1.length + list2.length comparisons.

See this website (https://yongdanielliang.github.io/animation/web/MergeSortNew.html) for an animation of the implementation.

Write a test program named MergeTest.java that prompts the user for the lengths and contents of two sorted lists.

Here is a sample run, with user input: Enter size of list 1: 5 Enter items in list 1: 1 5 16 91 248 Enter size of list 2: 4 Enter items in list 2: 2 4 5 27 list1 is 1 5 16 91 248 list2 is 2 4 5 27 The merged list is: 1 2 4 5 5 16 27 91 248

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!