CS 210 Lab 5

Due:  October 13, 1998

 

Part 1.

Analyze your StringList functions insert, length and display in terms of time and space complexity.  For space complexity, how many bytes of space will be required for N students and M time slots?  For time complexity exactly how many steps will the program run for each of the functions assuming that N students and M time slots have already been inserted into the list?  It is probably best to answer this question by printing out your functions and writing the number of times each line will execute next to the corresponding line.  Now write the time complexity of each of the functions in Theta Notation.
 

Part 2.

Show that the following inequalities are incorrect.

a)  10n2 + 9 = O(n).
b) n32n + 6n23n = O(n32n)
 

Part 3.

Let A and B be two programs that perform the same task.  Let tA(n) and tB(n), respectively, denote their run times.  For each of the following pairs, find the range of n values for which program A is faster than program B.

a)  tA(n) = 1000n, tB(n) = 10n2.
b)  tA(n) = 2n2, tB(n) = n3.
c)  tA(n) = 2n, tB(n) = 100n
 

Lab 5 deliverables

Please hand in your answers to all parts of the lab by 5:00 on October 13 as well, of course, as Lab 4.