Tutorial #2 Problems

  1. Rank the following functions by order of growth. That is, order them so that f1 ∈ O(f2), f2 ∈ O(f3), etc. Make sure to indicate whether or not fi ∈ Θ(fi+1). For instance you could use the notation O(n) ⊂ O(n^2) = O(2n^2) ⊂ O(n^4)...
    n3 – n  n 
    n! log (log n) 1.01n
     n log n 
    17 4913n289 32n-17
    1.011.01n  n 
    3n nn
    n18/17 n log17 n 32n n3 + log n
  2. Prove that for each fixed value of k > 0, 1k + 2k + … + (t-1)k + tk ∈ Θ(tk+1). Hint: do not use induction. Instead, treat as a constant, and do O and Ω separately. (Remember that for Ω bounds, it is legal to drop positive terms and reduce the size of positive terms, since you can guarantee that the resulting function is still a lower bound on the original.)
  3. Analyze the running time of the following algorithm as a function of n, assuming that each arithmetic operation takes constant time. Use O, Ω or Θ notation as appropriate to express your result as simply and as precisely as possible. Give an informal argument (not necessarily a full proof) to support your answer. (It may help to think about the “measure of progress” approach the book used to analyze the while loop in the Gale-Shapley Algorithm.)
    Algorithm Strange(n)
        sum ← 0
        while (n > 3) do
            sum ← sum + n
            if (n is even) then
                n ← n / 2
            else
                n ← n + 3
            endif
        return sum
    

Leave a Reply

Your email address will not be published. Required fields are marked *