YCP Logo Lab 13: List Reversal

Due: Friday, Oct 21st by 11:59 PM

Getting Started

Download CS201_Lab13.zip. Import it into Eclipse (File->Import...->Existing Projects into Workspace->Archive File.) You should see a project called CS201_Lab13 in the package explorer.

Your Task

Part 1 - Reversing a List using get and set

Implement the method called reverseUsingGetAndSet in the Reverse class. This method should reverse the elements of the List<E> object passed as the parameter by calling the get(int) and set(int, E) methods. A possible algorithm is suggested in the comment inside the method.

You can run the ReverseTest JUnit test class to test your implementation of the reverseUsingGetAndSet method.

Part 2 - Benchmark List reversal for ArrayList and LinkedList

Once the reverseUsingGetAndSet method is implemented, write a benchmark program which measures how long the reversal takes for both ArrayList<E> and LinkedList<E> objects with 10,000, 20,000, 30,000, etc. elements, up to and including 100,000 elements.

Add your benchmarking code to the Benchmark class. The main method is already partly implemented. You can call the createArrayList and createLinkedList methods to create array lists and linked lists with a specified number of elements.

Output each data point in the format


where times are measured in milliseconds. (See the description for Lab 10 for how to measure the execution time of a chunk of code. Don't forget to call the System.gc() method before starting the timing, to avoid including garbage-collection overhead in your measurement.)

You should see output something like the following:


Note that it will probably take a few minutes for the entire benchmark to complete.

Once you have collected your data, plot it in Excel. Your plot should look something like this:


Copy your Excel file into the Eclipse project. (Put it in the subdirectory of your Eclipse workspace called CS201_Lab13, and in Eclipse right-click on the project and choose Refresh.)


Make sure that you have included your Excel file in the project!

When you are done, save the project (CS201_Lab13) to a zip file by right-clicking it and choosing

Export...->Archive File

Upload the saved zip file to the Marmoset server as lab13. The server URL is