lec2 - n implying f n is O g n constant f n is Θ g n...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Rule of the game Our Question: can we do “better”? What is “better”? Less running time Less space usage How to measure? Asymptotic notation In Which Environment? RAM model: our virtual computer * Random memory access 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
* All memory accesses are the same, done in constant time * This is not a real computer How we program? Pseudocode No worry about syntax details Looks like Java code Implementable by programmers (like you) 2
Background image of page 2
Asymptotic Notations and Definitions Assume f ( n ) and g ( n ) are functions from the non-negative real numbers to the non-negative real numbers. We define: Notation Definition f ( n ) is c > 0 and n 0 > 0, O ( g ( n )) s.t. ( n n 0 )( f ( n ) cg ( n )) f ( n ) is c > 0 and n 0 > 0, Ω( g ( n )) s.t. ( n n 0 )( f ( n ) cg ( n )) f ( n ) is f ( n ) is O ( g ( n )) and = Θ( g ( n )) f ( n ) is Ω( g ( n )) f ( n ) is c > 0 , n 0 > 0 < o ( g ( n )) s.t. ( n n 0 )( f ( n ) < cg ( n )) f ( n ) is c > 0 , n 0 > 0 > ω ( g ( n )) s.t. ( n n 0 )( f ( n ) > cg ( n )) Some examples 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Prove Using Limits We compute lim n →∞ f ( n ) g ( n ) Value Asymptotic bound 0 f ( n ) is o ( g
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ( n )), implying f ( n ) is O ( g ( n )) constant f ( n ) is Θ( g ( n ), implying f ( n ) is O ( g ( n )) and Ω( g ( n )) ∞ f ( n ) is ω ( g ( n )), implying f ( n ) is Ω( g ( n )) Some examples 4 Useful Math Formulae • Logorithmic – x = log a b ⇔ a x = b – log a b = log c a log c b – a log b c = c log b a – log a +log b = log ( ab );log a-log b = log a b – log( a b ) = b log a • Series and Summation – ∑ n i =1 i = n ( n +1) 2 – ∑ n-1 i =0 q i = 1-q n 1-q (Geometric series) – ∑ n i =1 1 i is O (log n ) (Harmonic series) • L’Hˆopital rule (our commonly used version) If lim n →∞ f ( n ) = lim n →∞ g ( n ) = ∞ Then lim n →∞ f ( n ) g ( n ) = lim n →∞ f ( n ) g ( n ) 5...
View Full Document

This note was uploaded on 07/17/2010 for the course CS 240 taught by Professor Ortiz during the Spring '09 term at Waterloo.

Page1 / 5

lec2 - n implying f n is O g n constant f n is Θ g n...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online