# Question In chapter 1, you learned how to merge two sorted lists and get a third list which is also sorted. Using the LinkedList implementation (posted to the classroom), write a method named mergeUnsortedLists in an application, which given two unsorted lists listl and list2, merge their nodes together to make one new list list3, by taking nodes alternately between the two lists. For example, if list I contains $$[1,5,3]$$ and list2 contains $$[7,13,11,8,10]$$ then they will be merged into list 3 which will contain $$[1,7,5,13,3,11,8,10]$$. Note that if either list (list I or list2) runs out of nodes, then all the nodes in the other list should be added to list3. Write a main method to test this method in which you output the content of the three lists after the merge operation. The header of the method is given below. Note: Use the class LinkedList posted to the classroom. public static Linkedlist mergeUnsortedi.ists (LinkedList 1ist1, LinkedIist list2) ( Problem 2 Write an application that contains a method called multiply that takes a LinkedL ist 11 and returns a new Linkedl ist 12, of the same length, such that node $$i$$ of 1.2 contains the product of the data in 11 's nodes up to and including node $$i$$ of list 11 . The header of the method multiply is public static LinkedList multiply(LinkedList 11) ( Write also the main method in which you create the linked list 11 below then call the method multiply and pass to it 11. Finally, display the returned linked list 12. Note: Use the class Linkedl ist posted to the classroom. A linked list is considered a subset of another linked list if all its elements are included in the other. Write an application which contains a boolean method called isSubset that accepts as parameters two linked lists and returns true if one list is a subset of the other and false otherwise. The header of the method isSubset is: public static boolean issubset (Linkedist a, Linkedisist b) I Write also the main method in which you create two linked lists listl and list2 using values entered by the programmer then call the method isSubset. Note: Use the class LinkedList posted to the classroom. Page 1 of 2 Problem 4 Add to the LinkedLi st class a method called swap that swaps the it node with the $$j^{\text {th }}$$ one using the header. pub1ic void swap(int i, int j) I For example, if the linked list is $$[22,33,44,55,66,77,88,99]$$. then swap $$(3,6)$$ will change the linked list to $$[22,33,77,55,66,44,88,99]$$. Write an application that contains a main method in which you create a linked list 11 then call the method swap and pass to it 11 . Display the content of the linked list 11 before and after the swap. Note. Use the class Linkedl ist posted to the classroom.

ILAVD4 The Asker · Computer Science

Transcribed Image Text: In chapter 1, you learned how to merge two sorted lists and get a third list which is also sorted. Using the LinkedList implementation (posted to the classroom), write a method named mergeUnsortedLists in an application, which given two unsorted lists listl and list2, merge their nodes together to make one new list list3, by taking nodes alternately between the two lists. For example, if list I contains $$[1,5,3]$$ and list2 contains $$[7,13,11,8,10]$$ then they will be merged into list 3 which will contain $$[1,7,5,13,3,11,8,10]$$. Note that if either list (list I or list2) runs out of nodes, then all the nodes in the other list should be added to list3. Write a main method to test this method in which you output the content of the three lists after the merge operation. The header of the method is given below. Note: Use the class LinkedList posted to the classroom. public static Linkedlist mergeUnsortedi.ists (LinkedList 1ist1, LinkedIist list2) ( Problem 2 Write an application that contains a method called multiply that takes a LinkedL ist 11 and returns a new Linkedl ist 12, of the same length, such that node $$i$$ of 1.2 contains the product of the data in 11 's nodes up to and including node $$i$$ of list 11 . The header of the method multiply is public static LinkedList multiply(LinkedList 11) ( Write also the main method in which you create the linked list 11 below then call the method multiply and pass to it 11. Finally, display the returned linked list 12. Note: Use the class Linkedl ist posted to the classroom. A linked list is considered a subset of another linked list if all its elements are included in the other. Write an application which contains a boolean method called isSubset that accepts as parameters two linked lists and returns true if one list is a subset of the other and false otherwise. The header of the method isSubset is: public static boolean issubset (Linkedist a, Linkedisist b) I Write also the main method in which you create two linked lists listl and list2 using values entered by the programmer then call the method isSubset. Note: Use the class LinkedList posted to the classroom. Page 1 of 2 Problem 4 Add to the LinkedLi st class a method called swap that swaps the it node with the $$j^{\text {th }}$$ one using the header. pub1ic void swap(int i, int j) I For example, if the linked list is $$[22,33,44,55,66,77,88,99]$$. then swap $$(3,6)$$ will change the linked list to $$[22,33,77,55,66,44,88,99]$$. Write an application that contains a main method in which you create a linked list 11 then call the method swap and pass to it 11 . Display the content of the linked list 11 before and after the swap. Note. Use the class Linkedl ist posted to the classroom.
More
Transcribed Image Text: In chapter 1, you learned how to merge two sorted lists and get a third list which is also sorted. Using the LinkedList implementation (posted to the classroom), write a method named mergeUnsortedLists in an application, which given two unsorted lists listl and list2, merge their nodes together to make one new list list3, by taking nodes alternately between the two lists. For example, if list I contains $$[1,5,3]$$ and list2 contains $$[7,13,11,8,10]$$ then they will be merged into list 3 which will contain $$[1,7,5,13,3,11,8,10]$$. Note that if either list (list I or list2) runs out of nodes, then all the nodes in the other list should be added to list3. Write a main method to test this method in which you output the content of the three lists after the merge operation. The header of the method is given below. Note: Use the class LinkedList posted to the classroom. public static Linkedlist mergeUnsortedi.ists (LinkedList 1ist1, LinkedIist list2) ( Problem 2 Write an application that contains a method called multiply that takes a LinkedL ist 11 and returns a new Linkedl ist 12, of the same length, such that node $$i$$ of 1.2 contains the product of the data in 11 's nodes up to and including node $$i$$ of list 11 . The header of the method multiply is public static LinkedList multiply(LinkedList 11) ( Write also the main method in which you create the linked list 11 below then call the method multiply and pass to it 11. Finally, display the returned linked list 12. Note: Use the class Linkedl ist posted to the classroom. A linked list is considered a subset of another linked list if all its elements are included in the other. Write an application which contains a boolean method called isSubset that accepts as parameters two linked lists and returns true if one list is a subset of the other and false otherwise. The header of the method isSubset is: public static boolean issubset (Linkedist a, Linkedisist b) I Write also the main method in which you create two linked lists listl and list2 using values entered by the programmer then call the method isSubset. Note: Use the class LinkedList posted to the classroom. Page 1 of 2 Problem 4 Add to the LinkedLi st class a method called swap that swaps the it node with the $$j^{\text {th }}$$ one using the header. pub1ic void swap(int i, int j) I For example, if the linked list is $$[22,33,44,55,66,77,88,99]$$. then swap $$(3,6)$$ will change the linked list to $$[22,33,77,55,66,44,88,99]$$. Write an application that contains a main method in which you create a linked list 11 then call the method swap and pass to it 11 . Display the content of the linked list 11 before and after the swap. Note. Use the class Linkedl ist posted to the classroom.