$29
Assignment Prefix: lab03
Points: 100
This is an individual programming assignment.
In this project you will be doing the following:
Create a NetBeans project named lab03 and ensure it is imported into Subversion.
In this assignment you will be using the generic ArrayBag and LinkedBag classes that you created in lab01 and lab02. Copy the code you wrote for those classes to your lab03 project.
Create an ExperimentalStudy class that contains a main method. You will want to use the code described in Chapter 4.1 of the text in order to track run times. You may want to use the System.nanoTime() method to get more accurate time. You should keep all of your code, but can comment out parts not being actively used. It may be a good idea to create separate static methods for the different tests to make it easier to control what code should be tested and run.
You will be testing 3 different methods for both the ArrayBag and LinkedBag classes.
Test 1:
For the add method you should run 5 tests each for all sample sizes. Record the 5 times (and their average) below. When running these tests you should use ArrayBag and LinkedBag of type Integer. You can use the Random class to generate input values.
ArrayBag add(T item) 100 10,000 1,000,000
Run 1
Run 2
Run 3
Run 4
Run 5
Average:
LinkedBag add(T item) 100 100,000 1,000,000
Run 1
Run 2
Run 3
Run 4
Run 5
Average:
Test 2:
For the next series of tests you will need to create LinkedBag and ArrayBag objects that are already populated with values before starting the timer to test the remove methods. For the tests where you will remove 100 elements, you should create Bags of with 1,000 elements. For tests where you remove 10,000 elements, create Bags of size 100,000.
ArrayBag remove() 100 10,000
Run 1
Run 2
Run 3
Run 4
Run 5
Average:
LinkedBag remove() 100 10,000
Run 1
Run 2
Run 3
Run 4
Run 5
Average:
Test 3:
For the final set of tests you will need to create Bags that contain 10,000 and 1,000,000 starting elements before timing the methods for their respective tests. When generating the random data for these tests generate values in the range 0 – 99 inclusive. For each attempted removal, randomly generate a number in the same range.
ArrayBag remove(T value) 1,000 100,000
Run 1
Run 2
Run 3
Run 4
Run 5
Average:
LinkedBag remove(T value) 1,000 100,000
Run 1
Run 2
Run 3
Run 4
Run 5
Average:
Things to turn in:
• Ensure that your source code is committed to the SVN repository.
• Attach a copy of the different values for all of your experiments. You can use the tables provided as a part of this document or you can record the results in an Excel spreadsheet that you turn in.