Question: JAVA* At this point you will test how array bag and Linked bag implementations compare with respect to the time it takes some methods to

JAVA*

At this point you will test how array bag and Linked bag implementations compare with respect to the time it takes some methods to execute. We will test getCurrentSize(); contains(T anEntry); add(T anEntry); GetFrequencyOf(T anEntry); and remove(T anEntry.

a) Create an array-based bag that contains 100,000 random integers between 0 and 100,000

b) Get the bag size (it should match 100,000) (how long did this take in nanoseconds?)

c) Test whether the bag contains the perfect number 8128 (how long did this take in nanoseconds?)

d) Remove the last number from the bag, even if it is 8128 (how long did this take in nanoseconds?)

e) Add the number 8128 (the size of the bag should not have changed at this point. (how long did thid take in nanoseconds?)

f) Determine the frequency with which 8128 occurs (this could be 1). (how long did this take in nanoseconds?)

g) Double the size of the bag to 200,000 and fill the the bag with 100.000 more random integers while maintaining the same 100,000 integers that are already there. Clearly a call to the add method will return false if a fixed size array is used to to implement the ADT bag. Therefore we need to re-size the array, but maintain the name of the old array.

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!