Professional Documents
Culture Documents
Asymptotic Analysis and Conclusion PDF
Asymptotic Analysis and Conclusion PDF
Asymptotic Performance
• Simplifications
Ignore actual and abstract statement costs
Order of growth is the interesting measure:
o Highest-order term is what counts
Remember, we are doing asymptotic analysis
As the input size grows larger it is the high order term that
dominates
• Proof
Suppose runtime is an2 + bn + c
o If any of a, b, and c are less than 0 replace the constant
with its absolute value
an2 + bn + c (a + b + c)n2 + (a + b + c)n + (a + b + c)
3(a + b + c)n2 for n 1
Let c’ = 3(a + b + c) and let n0 = 1
• Question
Is InsertionSort O(n3)?
Is InsertionSort O(n)?
David Luebke 41 2/20/2017
Big O Fact
• Theorem
f(n) is (g(n)) iff f(n) is both O(g(n)) and (g(n))
Proof: someday
250
f(n) = n
f(n) = log(n)
f(n) = n log(n)
f(n) = n^2
f(n) = n^3
f(n) = 2^n
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
500
f(n) = n
f(n) = log(n)
f(n) = n log(n)
f(n) = n^2
f(n) = n^3
f(n) = 2^n
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1000
f(n) = n
f(n) = log(n)
f(n) = n log(n)
f(n) = n^2
f(n) = n^3
f(n) = 2^n
0
1 3 5 7 9 11 13 15 17 19
5000
4000
f(n) = n
f(n) = log(n)
3000
f(n) = n log(n)
f(n) = n^2
2000 f(n) = n^3
f(n) = 2^n
1000
0
1 3 5 7 9 11 13 15 17 19
10000000
1000000
100000
10000
1000
100
10
1
1 4 16 64 256 1024 4096 16384 65536
• Solving recurrences
Substitution method
Master theorem