Transciber’s notes:

Big-Oh–Part I

CMPT 225

Slide 1

Consider f(n),g(n):

Claim: f(n)=O(g(n))f(n) = O(g(n))

Why:

Also:

(A graph a cannot transcribe because the notation doesn’t make any sense. All future graphs have complexity on the y axis and the value of n [input to the function] as the x asxis.)

Claim: f(n) is not O(g(n))

However large we choose c,n0c,n_{0}, there will be some k (larger than n0n_0) s.d.: n>k    f(n)>cg(n)n > k \implies f(n) > c g(n)

Consider O(1) (i.e. g(n)=1g(n)=1)

f(n)=O(1)f(n) = O(1) if n0,c>0\exists n_{0},c > 0 s.t. n>n0  f(n)c×1\forall n>n_{0} \space \space f(n) \leq c\times 1

(Another graph that makes no Goddamn sense whatsoever.)

The constant does not matter

Fact: f(n)=O(1)    f(n)=O(1027)    f(n)=O(11027)f(n) = O(1) \iff f(n)=O(\text{10}^{27}) \iff f(n) = O(\frac{1}{\text{10}^{27}})

Suppose: f(n)=O(1027)f(n) = O(\text{10}^{27}) *

Claim: f(n)f(n) is also O(11027)O(\frac{1}{\text{10}^{27}})

* means n0,c>0\exists n_{0},c > 0 s.t. n>n0    f(n)c×1027n > n_{0} \implies f(n) \leq c\times\text{10}^{27}

Want to show: n0,c1>0\exists n_{0},c^{1}>0 s.t. n>n0    f(n)c1×11027n>n_{0} \implies f(n) \leq c^{1}\times \frac{1}{\text{10}^{27}}

Choose c1c^1 big enough that c111027c×1027c^{1} \frac{1}{\text{10}^{27}} \leq c \times \text{10}^{27}

e.g: c1=c×1054c^{1} = c \times \text{10}^{54}

Then:

n>n0,f(n)c×1027c×10271054c11027 \forall n>n_{0}, f(n) \leq c \times \text{10}^{27} \\ \leq c \times \text{10}^{-27} - \text{10}^{54}\\ \leq c^1 - \text{10}^{-27}

(54-27=27)

So: f(n)=O(1027)f(n)=O(\text{10}^{-27})

Asymtotic Notation (e.g. Big-Oh)

Ex. Complexity of Palindrome Checking

What does n×O(1)=O(n)n\times O(1) = O(n) mean?

It means: f(n)=O(1)    n×f(n)=O(n)f(n) = O(1) \iff n\times f(n) = O(n)

To see if it is true:

f(n)=O(1)    c>0 s.t. f(n)<c,for any nZ    c>0 s.t. n×f(n)<c×n,for any nN    n×f(n)=O(n) f(n) = O(1) \iff \exists c>0 \space \text{s.t.} \space f(n) < c, \text{for any} \space n \in \Z\\ \iff \exists c>0 \text{ s.t. } n\times f(n) < c\times n, \text{for any } n \in \N\\ \iff n\times f(n) = O(n)

End