Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Office hours:
◦ Sunday 10:00 -12:00
◦ Wednesday 1:00 -3:00
Lecture Participation
Assignments
Asymptotic Notation
Asymptotic Performance
Techniques
◦ Brute force?
◦ Greedy technique?
◦ ....
Temp = y
Y=0 y=x%y
x = temp
YES
Output
x
To Analyse an Algorithm:
◦ Prove that it works
◦ Prove its correctness
◦ Derive its complexity = performance analysis
Average case
◦ Provides the expected running time
◦ Very useful, but treat with care: what is “average”?
Random (equally likely) inputs
Real-life inputs
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
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
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
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
1000000
100000
10000
1000
100
10
1
1 4 16 64 256 1024 4096 16384 65536
In general a function
◦ f(n) is (g(n)) if positive constants c and n0 such
that 0 cg(n) f(n) n n0
Theorem
◦ f(n) is (g(n)) iff f(n) is both O(g(n)) and (g(n))