Lec01 PDF
Lec01 PDF
Anlisis de Algoritmos
Clave:
No. De horas /semana:
Duracin semanas:
Total de Horas:
No. De crditos:
Prerrequisitos:
Conocimientos previos
Recomendados:
CI7102-T
4
16
4
8
CI7100-T
Programacin
Anlisis de Algoritmos
Profesor:
Email:
Tel:
Web page:
Plataforma:
Lugar:
Horario:
Consultas
Breves:
Largas:
Toca mi puerta
Cita x email
2/24/16
Anlisis de Algoritmos
Evaluacin
4 exmenes
Intro y recurrencia
Ordenamientos
Grafos
Diseo y Anlisis
~50%
3 proyectos
Ordenamientos
Grafos
Diseo y Anlisis
~50%
Participacin
hasta 10%
Anlisis de Algoritmos
Libro:
Introduction to
Algorithms,
Third Edition,
Cormen et al.
2/24/16
Algorithm
a sequence of computational steps that transform the input (a set of values) into the output.
a tool for solving a well-defined computational problem
Output:
A permutation (reordering) a1, a2, . . . , an of the input sequence such that a1 a2 an
An algorithm is said to be correct if , for every input instance, it halts with the correct output
Enabling Internet
search engines
network routing algorithms
cryptography / network security
2/24/16
= 20 seconds
2/24/16
Floor
Ceiling
2/24/16
2/24/16
2/24/16
2/24/16
2/24/16
k = 1+ 2 + 3 +!+ n =
k =1
n
n(n + 1)
2
= 12 + 2 2 + 32 + ! + n 2 =
k =1
k 3 = 13 + 23 + 33 + ! + n3 =
k =1
n(n + 1)(2n + 1)
6
n 2 (n + 1) 2
4
xk = 1+ x + x2 + !+ xn =
k =0
If | x |< 1
lim x = x k =
n
k =0
x n+1 1
x 1
k =0
1
1 x
10
2/24/16
(cont.)
Harmonic Series
n
1
1 1
1
= 1 + + + ! = ln n + O(1)
2 3
n
k =1 k
Hn =
k =0
1
1 x
kx
k =0
x
(1 x) 2
for | x |< 1
Inductive hypothesis:
Assume formula is true for an arbitrary n
11
2/24/16
Induction Example 1:
n
k = 1+ 2 + 3 +!+ n =
Prove that
k =1
Basis:
Inductive hypothesis:
If n = 1, then
1 =? 1(1+1) / 2
n(n + 1)
for n 1
2
Yes, TRUE
(n + 1)((n + 1) + 1)
2
1 + 2 + 3 + ! + n + (n + 1)
n(n + 1)
n(n + 1) + 2(n + 1)
+ (n + 1) =
2
2
(n + 1)(n + 2)
2
Induction Example 2:
n
k
Prove that
k =1
= 12 + 2 2 + 32 + ! + n 2 =
Basis: If n = 1, then 12
Inductive hypothesis:
Assume formula is true for n
=?
n(n + 1)(2n + 1)
6
1(1+1)(2*1+1) / 6
12 + 22 + 32 + ! + n 2 =
12 + 22 + 32 + ! + n 2 + (n + 1) 2 =
Yes, TRUE
n(n + 1)(2n + 1)
6
(n + 1)(n + 2)[2 * (n + 1) + 1]
6
n(n + 1)(2n + 1)
n(n + 1)(2n + 1) + 6(n + 1) 2
+ (n + 1) 2 =
6
6
n(n + 1)(2n + 1) + 6(n + 1) 2 (n + 1)[n(2n + 1) + 6(n + 1)]
=
6
6
(n + 1)[n(2n + 1) + 6(n + 1)] (n + 1)(2n 2 + 7n + 6) (n + 1)(n + 2)(2n + 3)
=
=
6
6
6
12