Question: using java INode next 1) (15 pts) myList and mylist2 point to two different singly linked lists. Create a swap function that exchanges the data

 using java INode next 1) (15 pts) myList and mylist2 point

using java

INode next 1) (15 pts) myList and mylist2 point to two different singly linked lists. Create a swap function that exchanges the data elements between the two lists. The nodes are identified by number and are passed as parameters. For example, to exchange node 2 from myList with node 3 from myListz, cal swap (myusti 2. myust23 CAUTION: Keep in mind that you are not exchanging the nodes, only the data values Here is an Example: myListi: 10 20 myList2:50 80 90 100 3 0 70 (myList is the head of the first list) (myList2 is the head of the second list) Node 1 Node 4 Node number myusu myusa 10 Node 2 20 80 Node 3 90 100 30 50 70 Example: Given the following call: swap(myList1, 2, myList2, 3); The contents of myListland myList2 after the function call would be as such myList: 10 100 90 30 myList2: 50 80 20 70 Precondition: The items swapped will be valid. In other words, they will not be outside the list. Th lists will not be empty. They will contain nodes. inction header swap(Node myList 1, int a, Node myList2, int b){ urt here This is the last part you should do de to get the location of node in list1! // Code to Swap the data. You are swapping two ints. the second part you should do get to the location of node in list2 INode next 1) (15 pts) myList and mylist2 point to two different singly linked lists. Create a swap function that exchanges the data elements between the two lists. The nodes are identified by number and are passed as parameters. For example, to exchange node 2 from myList with node 3 from myListz, cal swap (myusti 2. myust23 CAUTION: Keep in mind that you are not exchanging the nodes, only the data values Here is an Example: myListi: 10 20 myList2:50 80 90 100 3 0 70 (myList is the head of the first list) (myList2 is the head of the second list) Node 1 Node 4 Node number myusu myusa 10 Node 2 20 80 Node 3 90 100 30 50 70 Example: Given the following call: swap(myList1, 2, myList2, 3); The contents of myListland myList2 after the function call would be as such myList: 10 100 90 30 myList2: 50 80 20 70 Precondition: The items swapped will be valid. In other words, they will not be outside the list. Th lists will not be empty. They will contain nodes. inction header swap(Node myList 1, int a, Node myList2, int b){ urt here This is the last part you should do de to get the location of node in list1! // Code to Swap the data. You are swapping two ints. the second part you should do get to the location of node in list2

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!