Professional Documents
Culture Documents
Goodrich 6e Ch04 Analysis
Goodrich 6e Ch04 Analysis
Analysis of Algorithms
Running Time
80
with the input size.
60
Average case time is often
difficult to determine. 40
running time. 0
1000 2000 3000 4000
Easier to analyze
Input Size
Crucial to applications such as
games, finance and robotics
Studies 8000
7000
Write a program 6000
Time (ms)
implementing the 5000
algorithm 4000
Run the program with
3000
inputs of varying size
and composition, 2000
g(n) = n2
g(n) = lg n
g(n) = n
g(n) = n3
c lg n c lg (n + 1) c (lg n + 1) c(lg n + 2)
cn c (n + 1) 2c n 4c n
~ c n lg n 2c n lg n + 4c n lg n + runtime
c n lg n quadruples
+ cn 2cn 4cn
when
c n2 ~ c n2 + 2c n 4c n2 16c n2 problem
size doubles
c n3 ~ c n3 + 3c n2 8c n3 64c n3
c 2n c 2 n+1 c 2 2n c 2 4n
1
1 10 100 1,000
n
big-Theta
f(n) is (g(n)) if there are constants c’ > 0 and
c’’ > 0 and an integer constant n0 1 such that
c’g(n) f(n) c’’g(n) for n n0
equal to g(n)