

























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


























































































Running Time
Big-Oh and Approximate Running Time
Big-Oh for Programs
Analyzing Function Calls
Analyzing Recursive Functions
Towers of Hanoi
Further Information
want a time answer which is related to the size of the input.
continued
size of n
running time constant * n
to compare their relative running times
1 .1. Different Kinds of Running Time
T(n)
value
input size n
Ta(n) = 100n
Tb (n) = 2n^2
n 3 9 50 100 1ms 1sec n^2 9 81 2.5ms 10ms 1sec 12 days n^3 27 729 125ms 1sec 16.7 min 31,710yr 2 n^8 512 36yr 410^16 yr 310^287 yr 3*10^301016 yr log n 2 3 6 7 10 20
n (no. of instructions)
growth formula T()
if n is 50, you will wait 36 years for an answer!
Assume 1 instruction takes 1 microsec (10-6^ secs) to execute. How long will n instructions take?
continued
continued
the process of estimating the running time of programs
continued
independent of: