This preview shows pages 1–19. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 11More onO()andΘ()NotationLast updated April 27, 201021We have seen the formal definitions of(a)f(n) =O(g(n))and(b)f(n) = Θ(g(n)).Informallyf(n) =O(g(n))means thatf(n)grows no faster thang(n)andf(n) = Θ(g(n))means thatf(n)grows likeg(n).22We have seen the formal definitions of(a)f(n) =O(g(n))and(b)f(n) = Θ(g(n)).Informallyf(n) =O(g(n))means thatf(n)grows no faster thang(n)andf(n) = Θ(g(n))means thatf(n)grows likeg(n).We will now see more about using this notation.31Functionf(n) =O(g(n)):(read:f(n)isOofg(n))Ifsuch that∀x≥xf(x)≤cg(x).If (i) There is some positivex∈R(ii) There is some positivec∈RRecall The Definition:414n28n2+ 2n3n2/5 +√n10 lognn(n3)are allO(n2).SomeExamples424n28n2+ 2n3n2/5 +√n10 lognn(n3)are allO(n2).SomeExamplesStatements like these can often be proven usingsimple tools;It is NOT usually necessary to provef(x) =O(g(x))from scratch!51Observation 1:If∃xand∃c >such that∀x > x,f(x)≤cThenf(x) =O(1)52Observation 1:If∃xand∃c >such that∀x > x,f(x)≤cThenf(x) =O(1)This comes directly from definition ofO(1)53Observation 1:If∃xand∃c >such that∀x > x,f(x)≤cThenf(x) =O(1)This comes directly from definition ofO(1)Examples:sin(x) =O(1)2 +1x=O(1)61Observation 2:“Constants don’t matter”62Observation 2:“Constants don’t matter”Iff(x) =O(g(x))then∀c >,f(x) =O(cg(x)))63Observation 2:“Constants don’t matter”Iff(x) =O(g(x))then∀c >,f(x) =O(cg(x)))Proof:f(x) =O(g(x))means that∃x,csuch that∀x > x,f(x)≤cg(x)).But then,∀x > x,f(x)≤cccg(x)),sof(x) =O(cg(x))).64Observation 2:“Constants don’t matter”Iff(x) =O(g(x))then∀c >,f(x) =O(cg(x)))Proof:f(x) =O(g(x))means that∃x,csuch that∀x > x,f(x)≤cg(x)).But then,∀x > x,f(x)≤cccg(x)),sof(x) =O(cg(x))).Examples:Iff(x) =O(12n2)thenf(x) =O(n2).Iff(x) =O(5)thenf(x) =O(1).71Observation 3:Iff1(x) =O(g1(x))andf2(x) =O(g2(x))thenf1(x) +f2(x) =O(g1(x) +g2(x))72Observation 3:Iff1(x) =O(g1(x))andf2(x) =O(g2(x))thenf1(x) +f2(x) =O(g1(x) +g2(x))Proof:∀x≥x1f1(x)≤c1g1(x).By definition, there existx1,c1,x2,c2, such that∀x≥x2f2(x)≤c2g2(x).73Observation 3:Iff1(x) =O(g1(x))andf2(x) =O(g2(x))thenf1(x) +f2(x) =O(g1(x) +g2(x))Proof:∀x≥x1f1(x)≤c1g1(x).By definition, there existx1,c1,x2,c2, such that∀x≥x2f2(x)≤c2g2(x).Lettingc3= max{c1,c2}andx3= max{x1,x2}gives∀x≥x3f1(x) +f2(x)≤c3(g1(x) +g2(x)).81Observation 3:Iff1(x) =O(g1(x))andf2(x) =O(g2(x))thenf1(x) +f2(x) =O(g1(x) +g2(x))Example:82Observation 3:Iff1(x) =O(g1(x))andf2(x) =O(g2(x))thenf1(x) +f2(x) =O(g1(x) +g2(x))Example:f1(x) =x2+ 3xf1(x) =O(x2)....
View Full
Document
 Spring '10
 M.J.Golin
 Computer Science

Click to edit the document details