List Insert Timing
CPE 103 Lab
Design an experiment to compare the performance of the two methods
below when
they are called with an ArrayList versus a Linked List.
public static void makeList1( List<Integer> list,
int N)
{
list.clear();
for (int i=N; i>0; i--)
{
list.add( i );
}
}
public static void makeList2( List<Integer> list,
int N)
{
list.clear();
for (int i=N; i>0; i--)
{
list.add( 0, i );
}
}
1. First, write in your lab notebook your theoretical predications
(based on the readings).
2. Write a short explanation of how you intend to confirm the
predictions experimentally.
3. Create a neat table in your lab notebook that records your
observations with
different sized lists.
4.
Perform the calculations based on your experimental data to determine the
order of magnitude for the running time for each dataset.
Show your calculations.
Interpret the data, explaining whether or not it is consistent
with your predictions.
If your experimental results differ from your predictions, explain what
you think
might be the cause. Write your explanations and conclusions in
your lab notebook.
5. If you have time, experiment with makeList1 to determine
the largest list you can create
on the lab computer without getting an "Out of Memory" exception.
(Your answer may be
approximate to the nearest ten thousand).