Discrete Mathematics Summer 2006. By Dan Barrish-Flood originally for Fundamental Algorithms For use by Harper Langston in D.M. What is an Algorithm?. A problem is a precise specification of input and desired output
By Dan Barrish-Flood originally for Fundamental Algorithms
For use by Harper Langston in D.M.
tJ is the number of times the “while” loop test in line 5 is executed for that value of j. Total running time is
c1 (n) + c2(n-1) +…+c8(n-1)
“Insertion sort runs in q(n2) time, worst-case.”
f(n) is monotonically increasing iff
I.e. It never “goes down” — always increases or stays the same.
For strictly increasing, replace £ in the above with <.
I.e. The function is always going up.
Yes! (But not strictly increasing.)
If , then is strictly increasing.
So even increases forever to
n = b log b n (definition)
logb(xy)=logbx + logby
logbx = logcx / logcb
logb(1/a) = -logba
logba = 1/(logab)
if b > 1, then logbn is strictly increasing.Log Facts
A polylogarithm is just
We’ve seen that 3n + 8 = O(n).
Is 10n = O(3n + 8)?
Yes: choose c = 10, n0 = 1:
10n£ 30n+ 80
2n2 + 5n - 8 = O(n2)?
2n2 + 5n - 8 £ cn2
¸n2: 2 + 5/n - 8/n2£c
Choose c = 3; subtracting 2:
5/n - 8/n2£ 1
Choose no = 5