Friday, November 7, 2014

CSC 165 big-Oh of polynomials, non-polynomials, limits

Week #9
Topic: big-Oh of polynomials, non-polynomials, limits

This week we talked about the big-Oh of polynomials. Polynomials seem to be a more accessible expression to work with. However, there is still a few observations that have to be made in order to master this topic.

One thing to remember when tackling this kind of problem is that we always follow a similar structure. In general terms, the structure is as follows:

O (n2) = {f: ≥0 | c +, B , n , n ≥ B f (n) ≤ cn2}

This is very similar to the structure to prove upper and lower bounds. For this reason, working with polynomials made me clarify my thoughts about the big-Oh proofs that dealt with counting steps and finding the worst-case.

Now, I understand that the argument in O (n2) determines the expression on the left hand side (f (n) ≤ cn2), which also happens for the worst case of n in (Ws (n) ≤ cn2).

Working with polynomials also made me understand how to pick a proper B. A case that we have to be careful with is when we have a constant:
k ≤ n2  only if n > 0, because otherwise, if n=0 then k is no longer less than n2.

In order to practice this week´s material I decided to work on the following exercise:

Prove 4 n2 + 5n + 6 O (n2 + 5n)
O (n2) = {f: ≥0 | c +, B , n , n ≥ B 4 n2 + 5n + 6  ≤ c (n2 + 5n)}
Pick c = 15. Then c +
Pick B = 1. Then B
Assume n ℕ #any typical natural number

            Assume n B # Antecedent
                        Then 4 n2 + 5n + 6 ≤ 4 n2 + 5 n2 + 6 ≤ 4 n2 + 5 n2 + 6 n2
                                                                                   = 15 n2 = c n2 c (n2 + 5n) 
                                                                                   # c = 15 B ≥ 1  
            Then n ≥ B 4 n2 + 5n + 6 ≤ c (n2 + 5n) # Introduce implication

Then n , n ≥ B 4 n2 + 5n + 6 ≤ c (n2 + 5n) # Introduce universal
Then B , n , n ≥ B 4 n2 + 5n + 6 ≤ c (n2 + 5n) # Introduce existential
Then c +, B , n , n ≥ B 4 n2 + 5n + 6 ≤ c (n2 + 5n) # Introduce existential

Then 4 n2 + 5n + 6 O (n2 + 5n) matches the definition.

No comments:

Post a Comment