Question: Can you please comment the thought process and then the code. Task Description: . (8 pts) Task 1: Add three methods: union, intersection, and difference


Can you please comment the thought process and then the code.
Task Description: . (8 pts) Task 1: Add three methods: union, intersection, and difference to the interface BagInterface for the ADT bag. The detailed description of the three methods and how to call the three methods could be found on pages 2 and 3 of this assignment. Note: the three methods to implement are for Bags, not for Sets. (36 pts) Task 2: Implement the three methods, union, intersection, and difference, for the class ResizeableArrayBag. Note: the class ResizeableArrayBag presents an implementation of the ADT bag using a resizable array. Generics are needed! (36 pts) Task 3: Implement the three methods, union, intersection, and difference, for the class LinkedBag. Note: the class LinkedBag presents an implementation of the ADT bag using a linked chain. Generies are needed! (10 pts) Task 4: Write a client program, "ArrayBag Test.java", which contains a main method to test the three methods (union, intersection, and difference) you implemented for the class ResizeableArrayBag. Note that when you examine the method "difference, please test both hag2 difference/bagl) and bag/ difference(bag2), given two bags bag2 and bag!. (10 pts) Task 5: Write a client program, "LinkedBagTest.java", which contains a main method to test the three methods (union, intersection, and difference) you implemented for the class LinkedBag. Note that when you examine the method "difference", please test both bag2 difference(bag!) and bagl difference/bag2), given two bags bag2 and bag! (Optional, Just for Extra Points: 10 pts) Task 6: Use Big O notations to indicate the time complexity of each method you implemented (the three methods implemented in Task 2 and the three methods implemented in Task 3) in the best case and the worst case, respectively. Please also provide explanations for your answers. Table 1. The time complexities of the three methods ResizeableArrayBag LinkedBag union intersection difference union intersection difference Time Complexity in the Best Case Time Complexity in the Worst Case nion The union of two collections consists of their contents combined into a new collection. Add a method union to the interface BagInterface for the ADT bag that returns as a new bag the union of the bag receiving the call to the method and the bag that is the method's one argument. Include sufficient comments to fully specify the method. Note that the union of two bags might contain duplicate items. For example, if object x occurs five times in one bag and twice in another, the union of these bags contains x seven times. Specifically, suppose that bagl and bag2 are Bag objects, where Bag implements BagInterface; bagl contains the String objects a, b, and c; and bag2 contains the String objects b, b, d, and e. After the statement BagInterface
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
