![Page 1: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/1.jpg)
CSC165 Week 9Larry Zhang, November 4, 2014
![Page 2: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/2.jpg)
![Page 3: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/3.jpg)
today’s outline
➔ exercises of big-Oh proofs
➔ prove big-Oh using limit techniques
![Page 4: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/4.jpg)
Recap definition of O(n²)
Beyond breakpoint B, f(n) is upper-bounded by cn², where c is some wisely chosen constant multiplier.
cn²
f(n)
B
![Page 5: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/5.jpg)
Notation of O(n²) being a set of functions
functions that take in a natural number and return a non-negative real number
beyond breakpoint B, f(n) is upper-bounded by cn²
set of all red functions which satisfy the green.
![Page 6: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/6.jpg)
Prove
thoughts: it’s all about picking c and B➔ tip 1: c should probably be larger than 3 (the
constant factor of the highest-order term)
➔ tip 2: see what happens when n = 1
➔ if n = 1
◆ 3n² + 2n = 3 + 2 = 5 = 5n²
◆ so pick c = 5, with B = 1 is probably good
◆ double check for n=2,3,4…, yeah it’s all good
![Page 7: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/7.jpg)
Proof# 3n²+2n ≥ 0 when n is natural number
# 5 is a positive real
# 1 is a natural number
# generic natural number
# the antecedent
# 2nx1 ≤ 2nxn since 1 ≤ n
# c = 5
# transitivity of ≤
# introduce antecedent
# introduce ∀
# introduce ∃# by definition
![Page 8: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/8.jpg)
![Page 9: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/9.jpg)
what if we add a constant?
thoughts: it’s all about picking c and B➔ tip 1: c should probably be larger than 3 (the
constant factor of the highest-order term)➔ tip 2: see what happens when n = 1➔ if n = 1
◆ 3n² + 2n + 5 = 3 + 2 + 5 = 10 = 10n²◆ so pick c = 10, with B = 1 is probably good◆ double check for n=2,3,4…, yeah it’s all good
Prove
![Page 10: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/10.jpg)
![Page 11: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/11.jpg)
Prove
thoughts: ➔ assume n ≥ 1
➔ upper-bound the left side by overestimating
➔ lower-bound the right side by underestimating
➔ choose a c that connects the two bounds
large
small
![Page 12: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/12.jpg)
Proof # non-negative for n ≥ 0
# -5n⁴ ≤ 0
# n³ ≤ n⁶ since n ≥ 1
# c = 9/2
# 0 ≤ n² # -n⁸ ≤ -n⁵
# n ≥ B, the antecedent
![Page 13: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/13.jpg)
how about disproving?
![Page 14: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/14.jpg)
Prove
➔ first, negate it
➔ then, prove the negation
![Page 15: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/15.jpg)
Prove
thoughts
![Page 16: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/16.jpg)
Proof:
# definition of max
# definition of max and ceiling
# multiply both sides by n² > 0
# conjunction introduction
# introduce ∃
# intro ∀
# definition of big-Oh
![Page 17: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/17.jpg)
summary
➔ the ways we talked about of picking c and B, the main point of them is that we know how to show the bounding relation when picking in these ways.
➔ these are not the only ways, you can be more flexible when you are more familiar with these types of proofs.
➔ In general, larger c or larger B don’t hurt.
![Page 18: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/18.jpg)
so far all functions we talked about are polynomials
➔ between polynomials, it is fairly easy to figure out who is big-Oh of whom
➔ simply look at the highest-degree term
➔ f(n) is in O(g(n)) exactly when the high-degree of f(n) is no larger than that of g(n)
![Page 19: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/19.jpg)
polynomials
![Page 20: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/20.jpg)
how about non-polynomials?
![Page 21: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/21.jpg)
but how do we prove it?➔ we need to use a math
tool, which we didn’t like a lot but studied anyway
![Page 22: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/22.jpg)
Intuition:
➔ if the ratio approaches infinity
when n becomes larger and larger, that
means f(n) grows faster than g(n)
f(n)
g(n)
![Page 23: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/23.jpg)
give me any big number
more precisely
I can find a breakpoint
beyond which
the ratio is bigger than that big number
This is sort-of related to the definition of big-Oh…
![Page 24: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/24.jpg)
How to use limit to prove big-Oh
General procedure
1. prove using “some calculus”
2. translate the limit into its definition with c
and n’, i.e.,
3. relate this definition to the definition of
big-Oh, i.e., means
![Page 25: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/25.jpg)
![Page 26: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/26.jpg)
Step 1. prove using “some calculus”
“some calculus”: L’Hopital’s rule
derivatives
l’hopital
l’hopital again!
http://mathworld.wolfram.com/LHospitalsRule.html
![Page 27: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/27.jpg)
Step 2. translate the limit into its definition
we have proven
then by definition of limit
give me any big number
I can find a breakpoint
beyond which
the ratio is bigger than that big number
![Page 28: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/28.jpg)
Step 3. relate it to the definition of big-Oh
wanna pick a wise n
we have this awesome n’, all n ≥ n’ satisfy 2^n > cn²
to satisfy both
pick n = max(n’, B)
what we have
![Page 29: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/29.jpg)
Proof: # generic c and B
# applying L’hopital’s rule twice, (show the steps, omitted here)
# definition of limit
# definition of max
# definition of max
# definition the limit
# conjunction introduction
# intro ∃
# intro ∀
# negation of definition of big-Oh
![Page 30: CSC165 Week 9 - Department of Computer Science, University of …ylzhang/csc165f14/slides/lec09.pdf · 2015. 11. 24. · CSC165 Week 9 Larry Zhang, November 4, 2014. today’s outline](https://reader033.vdocuments.mx/reader033/viewer/2022061001/60b09af4ce7a86797f7fcbab/html5/thumbnails/30.jpg)
next week
➔ more proofs on O, Ω, Θ
➔ (maybe) computability