Question: Write an intersection method for the ResizableArrayBag class. . The intersection of two bags is the overlapping content of the bags. Intersections are explained in

 Write an intersection method for the ResizableArrayBag class. . The intersection

Write an intersection method for the ResizableArrayBag class. . The intersection of two bags is the overlapping content of the bags. Intersections are explained in more detail in Chapter 1, #6. An intersecion might contain duplicates. The method should not alter either bag. The current bag and the bag sent in as a parameter should be the same when the method ends. The method header is: public BagInterface intersection (ResizableArrayBag anotherBag) Example: bag1 contains (1, 2, 2,3) bag2 contains (2, 2, 2, 4, 5) then bag1.intersection(bag2) would return a new bag that contains (2, 2) The contents of bag1 and bag2 would be the same (The order of the intersection bag might not match the above, since bags are unordered.)

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!