L08a

Due by the end of this meeting

Starter Files:


SUBMIT   /   Submission Summary

Comparing ArrayLists and LinkedLists using Timing Data

Activity 1
Consider the ListComparisons program from A06. Revise it to include a method sumElements(int numElts, Random rand, List<Double> list). This method generates a list of numElts values using rand.nextDouble(). It then adds up all those numbers. (It neither prints nor returns the sum! I just want it to do the math. Compare the randomAccess method.
Activity 2
Create a method testSumElements that compares how long it takes to add up the list of numbers using an ArrayList versus a LinkedList. (Base it on testRandomAccess.)

Call this method from main (right after testRandomAccess). Run the program several times, and add a comment (in main right after the call to testSumElements) saying whether ArrayLists or LinkedLists are faster, or whether they're about the same.

Your grade will be based on the following rubric:

Submit this/these files:


SUBMIT   /   Submission Summary