Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a public non-final class called Merger. It should provide one public class method called merge. Merge should accept two Lists of sorted Comparable Java
Create a public non-final class called Merger. It should provide one public class method called merge. Merge should accept two Lists of sorted Comparable Java objects and return one merged List of Comparableobjects. If both lists are null you should return null. If either is null you should return the other. If both are empty you should return an empty List.
Create a public non-final class called Merger. It should provide one public class method called merge. Merge should accept two Lists of sorted Comparable Java objects and return one merged List of Comparable objects. If both lists are null you should return null. If either is null you should return the other. If both are empty you should return an empty List. You will want to review the List documentation for an overview of helpful List operations. You will want to import java.util.List and a List implementation, probably java.util.ArrayList. Note that if you remove items from the list this will change the list's size, so you will need to consider how this impacts your loops. Finally your merge function can alter first and second if needed. We don't expect those lists to be the same after we call merge. As a reminder, first.compareTo(second) returns a positive value if first is larger than second, a negative value if first is smaller than second, and 0 if they are equalStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started