Earlier in this course, we wrote a WordBag class for maintaining a bag (multiset) of strings. To implement the class, we used an array of MyWord objects called myArray. In this problem, you should implement a class called ArrayListWordBag, a stub of which is given here. ArrayListWordBag should have the same functionality as WordBag, that is, support the same public methods. (One minor difference is that ArrayListWordBag has only one constructor, a zero-parameter one.) The signatures of the constructor and the public methods that ArrayListWordBag should support are included in the stub.
Your implementation of ArrayListWordBag should use aList, an ArrayList of MyWord objects, to store each string in the bag along with its frequency. (This is somewhat analogous to how myArray, an array of MyWord objects, was used in WordBag.) So you will have to use methods of aList (from the List and Collection interfaces) to update and search it.
As you may know from our class discussions, you will need to override the equals method from Object in MyWord. Your discussion section on 10/31 will show you an example of how this can be done.
For each method of ArrayListWordBag, estimate its running time as a function of n, the number of distinct words in the bag. You can assume that checking string equality takes constant time for this. Write the running time as comments accompanying the corresponding methods.
This problem is worth 8 points
Submit the source files into a dropbox in ICON called Homework6. This assignment is due by 11:59 pm on Monday, November 4.