Asymptotics III Study Guide
Author: Josh Hug and Kartik Kapur

C level

  1. Prove that if some operation takes O(N) time for the first N iterations and $O(N^{2})$ time for the $N+1$st operation, the amortized runtime is O(N). Remember that you can think of amortized runtime as the average runtime.

B level

  1. Problem 1 of my Spring 2013 midterm.

  2. Is it possible to have an Ω bound and O bound that are different for the best case?

  3. Find the tightest possible bounds for the following function using Ω bound and O where best is initially set to N.

     public void caGreeno(int bet, int N){
         double somenum = Math.random() //returns a double from 0 to 1
         double newnum;
         if(somnum < .5){
             newnum = Math.random();
             if(newnum < .5){
               caGreeno(bet/2, N);
               caGreeno(bet/2, N);
             }
             else{
               caGreeno(bet * 2/bet , N);
             }
         }
         else{
           newnum = Math.random();
           if(newnum < .5){
             caGreeno(bet - 50 , N);
             caGreeno(bet - 100, N);
           }
           else{
             caGreeno(bet - 1, N);
           }
         }
     }
    

A level

  1. Find the minimum ai such that the potential is never negative for this example from class.

  2. Suppose the optimal (and possibly unknown) solution to problem P has order of growth F(N). Suppose that the best known solution has runtime that is Θ(B(N)). Finally, suppose that there is a clever proof that no solution can possibly have order of growth that is less than L(N). Which of the following can you surmise?
    • F(N) = O(B(N))
    • B(N) = O(F(N))
    • The limit of $\frac{F(N)}{B(N)}$ as N goes to infinity cannot be infinity.
    • F(N) = Ω(L(N))
    • L(N) = Ω(F(N))
    • B(N) > F(N) for sufficiently large N.
  3. Find the runtime of the following function

     public void tree(int N){
         for(int i = 0; i < N; i++){
           System.out.println("Oi I'm a tree and I can't get up");
         }
         tree(Math.sqrt(N));
     }
    

A+ level

  1. We say that fibonnaci is O($2^n$). However, as we learned in this lecture, O is a bit of a blanket statement. There is in fact a tighter bound for fibonnaci called the golden ratio. Prove that the standard fibonnaci function runs in $O(1.618034^n)$