Due by the end of this meeting
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.
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.
Submit this/these files: