Question: Implement an instance method in IntLinkedBag, called split, that returns two linked lists as output ( i . e . , return data type is

Implement an instance method in IntLinkedBag, called split, that returns two linked lists as output (i.e., return data type is IntNode[]) where the first linked list include all the odd numbers in the bag while the second linked list include all the even number in the bag. For example, if the bag includes the following numbers [1,2,3,4,5,6], then the output lists will be as follows:
Odds list [1,3,5]
Evens list [2,4,6]
Write code in the driver to test your split method on the bag, called b, that is created in Exercise 1. To make sure the method works as expected, print the contents of the output lists.
Implement another instance method in IntLinkedBag, called splitV2, that is similar to split but returns two IntLinkedBag instead of two IntNode as output.
Write code in the driver to test your splitV2 method on the bag, called b, that is created in Exercise 1. To test the method, print the contents of the output bags.
JAVA

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!