1 / 10

Big O notation

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

Download Presentation

Big O notation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 c2 g(n) There are c1,c2>0, n0 so that for n>n0 c1g(n) ≤ f(n) ≤ c2g(n) c1 g(n): lower bound of f(n) c2g(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 • 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

More Related