Loyola College in Maryland
CS 631 - Computer Science II
Spring 2007
Loyola College >
Department of Computer Science >
Dr. James Glenn >
CS 631 >
Homework >
Homework #3
Due: Wednesday, February 14th at the beginning of class
- Add the removeRange method to our ArrayList631 class.
removeRange should take two indices are arguments and remove
from the list all of the elements between those two points (inclusive).
Write your method so it throws an exception if the arguments are invalid.
Write your method to be efficient. Compare the efficiency of your method
to a version that uses only the methods provided by the List ADT.
- Add the addAll method to ArrayList631. This method
should, given another list as an argument, add all the elements from the
argument to the end of the current list. The argument list should not be
changed. Write your method so the array is resized at most once.
- Add the shuffle method to ArrayList631. The statement
l1.shuffle(l2) should change l1 so that the elements from
l2 alternate with the elements originally on l1.
l2 should be empty after the method.
Write your method to be efficient. Compare the efficiency of your method
to a version that uses only the methods provided by the List ADT.