Presentation is loading. Please wait.

Presentation is loading. Please wait.

Big O notation f = O(g(n)) c g(n)

Similar presentations


Presentation on theme: "Big O notation f = O(g(n)) c g(n)"— Presentation transcript:

1 Big O notation f = O(g(n)) c g(n)
There are c>0, n0 so that for n>n0 f(n) ≤ c g(n) c g(n): upper bound of f(n) f(n) n0 [ Small o: for every c>0 there is n0 so that: f(n) ≤ c g(n) ]

2 Big Ω notation f = Ω(g(n)) f(n)
There are c>0, n0 so that for n>n0 c g(n) ≤ f(n) c g(n): lower bound of f(n) c g(n) n0 [ Small ω: for every c>0 there is n0 so that: c g(n) ≤ f(n) ]

3 Big Θ notation There are c1,c2>0, n0 so that for n>n0
c2 g(n) There are c1,c2>0, n0 so that for n>n0 c1 g(n) ≤ f(n) ≤ c2 g(n) c1 g(n): lower bound of f(n) c2 g(n): upper bound of f(n) f(n) c1 g(n)

4 ~ notation f(n)~g(n) f is equal to g asymptotically f(N) g(N)

5 Template for O(n) proofs

6 Examples 1. T(n) = (n+1)2 find upper bound for T(n)
2. Is n3 O(0.001n3) ?

7 Template for proving that O(n) is false

8 Example Prove that n2 is not O(n)

9 Recursion Very often a problem is decomposed to smaller ones
Solution to subproblem is simpler Solutions are combined iteratively

10 Examples T(N) = T(N-1) + N, N≥2, T(1)=1 T(N) = T(N/2)+1, N≥2, T(1)=1
Loops to eliminate one item T(N) = T(N/2)+1, N≥2, T(1)=1 Halve the input T(N) = T(N/2)+N, N≥2, T(1)=0 Halve the input but examine every item in the input T(N) = 2T(N/2)+N, N≥2, T(1)=0 Halve the input and linear pass


Download ppt "Big O notation f = O(g(n)) c g(n)"

Similar presentations


Ads by Google