Question: Write a subclass of SLL named SortedSLL that represents a sorted SinglyLinkedList (sorted in non- decending order). The class should contain the following methods:

Write a subclass of SLL named SortedSLL that represents a sorted SinglyLinkedList (sorted in non- decending

Write a subclass of SLL named SortedSLL that represents a sorted SinglyLinkedList (sorted in non- decending order). The class should contain the following methods: 1- [40 Points] void insert(Te) that inserts an SLLNode in its correct position so that the resulting list remains sorted. Make sure to consider special cases such as: The list is empty. The list has one element. The inserted element is smaller than the head, or larger than the tail.. - - 2- [60 Points] void merge (SortedSLL list) that merges the calling list with the argument list. Note that this can be done by calling the insert method for each element in list, but this is highly ineffiecient, answer the following question: Q2.1: What is the complexity of this approach? Explain. [10 Points] Instead, you should come up with a solution that traverse both lists just one time. Furthermore, the argument list should be empty after the merge is completed. Q2.2: What is the complexity of this approach? Explain. [10 Points] Hint: Make sure the class SortedSLL accepts types T that is comparable. You can do this by writing the class header as follows: public class SortedSLL extends SLL

Step by Step Solution

3.41 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here is the implementation of the SortedSLL class with the requested methods along with answers to t... 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 Programming Questions!