Homework Assignment #1
Due: Tuesday September 11
Create a linked list of n nodes. Plot the normalizing running time per
link (that is, total running time divided by n), for traversing your
list as n varies from 2^5 to 2^24 links in size (using powers of two).
Repeat the same experiment using a contiguous array of size n. Use the
elements in the array to index th e element in the list. Try different
instances where the array is traversed in sequential order, in strided
order, and in random order. For instance (using an array with
positions from 0 to 7, and -1 representing the end of list):
Sequential Order: 1, 2, 3, 4, 5, 6, 7, -1
Stride-2 Order: 2, 3, 4, 5 ,6, 7, -1
Random Order: 3, 1, 2, 7, 6, 5, 4, -1
You may wish to test correctness by setting a data field of link i to
integer i, adding the n numbers together during the list traversal,
and verifying that the result equals the sum of the integers from 1 to
n.
Describe your experimental methodology for getting accurate timings.
What is the asymptotic complexity of each algorithm?
Compare the normalized running times and analyze your results.
Is the algorithmic model accurate? Explain.
Please turn in a printout of your code, your plots, and analyses.