You are on page 1of 1

CS1332 Summer 2014!

Homework #1!

!
!

The following questions pertain to understanding Algorithm Analysis. Answer in a text file or pdf
and submit to t-square by midnite Friday 23 May.!

1.

!
2.
!

Experiments show algorithm A has a T(n) = 40n2. Algorithm B has a T(n) = 2n3. Determine
the n0 such that for which Algorithm A is better than B for all n >= n0.!
Show that if d(n) is O(f(n)) and f(n) is O(g(n)) then d(n) is O(g(n)).!

3. Al and Bob are always arguing over their algorithms. Al claims his O(n log n) algorithm is
always faster than Bobs O(n2). They finally decide to do some experiments and to Als surprise,
his algorithm is slower for n < 100 and it is only faster for n >=100. Explain how this could
happen.!

4.
!
!
!
!
!

Give a short phrase describing the following categories of runtimes:!


a. Best-Case!
b. Average-Case!
c. Worst-Case!
d. Amortized Time!
e. Expected Time!

5. Using the mathematical definition of Big-O, show that T(n) = 5n + 15 is O(n).

You might also like