Home Work Number 1, Intro to Algorithms, Fall 2012

Due on Thursday September 6
Please submit your answers in a plain paper (write your name and section number)
Do the following problems from the text book (DG - Dasgupta et al, CLRS - Cormen et al's book) - log(n) means logarithm to the base 2
  1. Exercise 0.2 (page 18 from DG or page 8 of DG in 2008 edition)
  2. Exercise 0.3 a and b (page 18 from DG or page 8 of DG in 2008 edition)
  3. Explain whether the following statements are true or false and why
    1. Is 2 n0.5 = Big-Oh(2 n )?
    2. Is 2 3n = Big-Oh(2 n )?
    3. Is 2 log(n) = Big-Oh(log(n) )?
  4. In the Lab0 problem you gave an algorithm to sort 4 elements with 5 switches. Here is one
    input a,b,c,d
    output: sorted(a,b,c,d) - a < b < c < d
    Algorithm:
    if (a > b) swap(a,b)
    if (c > d) swap(c,d) 
    if (b > d) swap(b,d) // d is the highest
    if (a > c) swap(a,c) // a is the smallest
    if (b > c) swap (b,c)
    
    Answer the following questions.
    1. How many swap instructions will be executed for the input (a,b,c,d order) 10, 20, 30, 40?
    2. How many swap instructions will be executed for the input (a,b,c,d order) 30,10,20,40?
    3. Give an input where all the five swap instructions are executed. (Hint: Think back from the output)
  5. Order (increasing) the following functions according to their Bih-Oh notation (Approximate each function by a Big-Oh notation and then Order (increasing) them) - Give a brief explanation
    n 0.5,   log(n0.5),  log(log((n)),   n!,  2n2,  n log(n) ,   n/log(n)