Home Work Number 1, Intro to Algorithms, Fall 2011

Due on Thursday September 8
Do the following problems (DG - refers to Dasgupta et al, CLRS refers to Cormen et al's book)
  1. Give big Oh Approximations for for the following quanitities:
    1. N + 1
    2. 1 + 1/N
    3. (1+ 1/N) (1 + 2/N)
    4. 2 N3 -15 N 2 + N
    5. log2(2N)  /  log2(N)
    6. log2 ( N2 + 1) /  log2 N
    7. N 100/2N
  2. Problem 1-1 (page 15 from CLRS - 3rd Edition, 13 in 2nd Edition)
  3. Exercise 0.1 (page 8 from DG)
  4. Exercise 0.3 parts a and b (page 9 from DG)
  5. Suppose that the vairables a,b,c and t are all of the same numeric primitive type. The following code puts a,b,c in ascending order. Your task is to do this (by modifying this code - no nested if statements) to put 4 items of same numberic types a,b,c,d in ascending order (please try to do this with as few an if statements as possible (5 are sufficient - you get full credit for 6 too) - Convince yourself why 5 is necessary too!).
    if ( a > b ) { t = a; a = b; b = t;}
    if ( a > c ) { t = a; a = c; c = t; }
    if ( b > c) { t = b; b = c; c = t;}