YCP Logo Assignment 5: Efficient List Reversal

Due: Monday, November 9th by 11:59 PM

Getting started

Start by importing the file CS201_Assign5.zip into Eclipse: File->Import->Existing Projects into Workspace, click Select archive file, select CS201_Assign5.zip from the file selection dialog, and then click the Finish button. You should see a project called CS201_Assign5 in the Package Explorer.

Your Task

This assignment is very similar to Lab 15. in that you will be implementing a method to reverse the elements of a List.

Your task is to implement the reverseEfficiently static method in the Reverse class. The method takes an object implementing the List<E> interface as a parameter. It should re-arrange the elements in the list so that they are placed in the reverse of their original order.

When called on either and ArrayList or LinkedList with N elements, the method must complete in O(N) steps. You will need to think carefully about how to design a reversal algorithm that is efficient for both ArrayList and LinkedList objects.

Hint: an "in-place" reversal strategy might not be the best choice.

Testing

You can use the provided ReverseTest JUnit test to test your method.

Submitting

Export your project as a zip file (File->Export...->Archive File) and upload it to the submission server as assign5. The URL of the server is

https://camel.ycp.edu:8443/