Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

7. Suppose we implement the IntArrayBag class using two partially-filled, \"para

ID: 3599982 • Letter: 7

Question

7. Suppose we implement the IntArrayBag class using two partially-filled, "parallel arrays" instead of a single (partially-filled) array. The first array, data, holds the values of the items in the bag and the second array, dataCounts, holds a count of the number of times that the associated item is in the bag. In other words, data[i] is an integer in the bag and dataCounts[i] is the number of times that integer is in the bag We assume that there is an instance variable manyDataItems that tells us how many of the entries from the partially-filled arrays data and dataCounts are used to hold items from the bag (so manyDataItems

Explanation / Answer

1->The capacity of the bag is the number of unique elements in data[ ].

The size of the data[ ] is 10,so the capacity of the bag is 10.

It can accomadate 10 unique items and the datacount of each item should be greater than 0.   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote