Question: Given is the IntNode class that represents an element in a linked list, and the IntList class that represents a linked list. Given that the

Given is the IntNode class that represents an element in a linked list, and the IntList class that represents a linked list. Given that the list is sorted in ascending order. public class IntNode { private int num; private IntNode next; public IntNode(int num, IntNode next) { this.num = num; this.next = next; } public int getNum() { return num; } public void setNum(int num) { this.num = num; } public IntNode getNext() { return next; } public void setNext(IntNode next) { this.next = next; } }

public class IntList { private IntNode head; public IntList() { head = null; } }

Add a method signed to the IntList class: public void merge(IntList other) The method will receive as a parameter a linked list sorted in ascending order. The method will merge the two lists in the following way - the method will copy the members of the list other to the given list, so that they enter in a sorted form, and after running the method, the given list will contain its original members and the members of other and it will be sorted. For example, if the given list is: 1-->4-->5-->8-->null And the other list is: 2-->4-->6-->7-->null so after running the method, the given list will be: 1-->2-->4-->4-->5-->6-->7-->8-->null

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!