n - Universidad de La Serena

Transcripción

n - Universidad de La Serena
Diseño y Análisis de Algoritmos
Preparándonos para Prueba1
Dr. Eric Jeltsch F.
Exercises
1)
T (1) = 1
T (n ) = T ( n2 ) + n
( )
T (n ) = O n ?, use substitution method.
-------------------------------------------------2) T(a) = Θ(1)
T(n) = T(n-a) + T(a) + n
Find T(n) using the iteration method.
--------------------------------------------------3) Use the Master method to find T(n) = Θ(?) in each of the following cases:
1. T(n) = 7T(n/2) + n2
2. T(n) = 4T(n/2) + n2
3. T(n) = 2T(n/3) + n3
---------------------------------------------------4) The sequence of Fibonacci is defined as follows:
f(0) = 0
f(1) = 1
f(n) = f(n-1) + f(n-2)
Find an iterative algorithm and a recursive one for computing element number n in Fibonacci
series, Fibonacci(n),. Analyse the running-time of each algorithm.
----------------------------------------------------
5) Hanoi towers problem:
n discs are stacked on pole A. We should move them to pole C, keeping the following
constraints:
1. We can move a single disc at a time.
2. We can move only discs that are placed on the top of their pole.
3. A disc may be placed only on top of a larger disc, or on an empty pole.
Analyze the given solution for the Hanoi towers problem; how many moves are needed to
complete the task?
Escuela Ingeniería en Computación, Universidad de La Serena.
Diseño y Análisis de Algoritmos
Preparándonos para Prueba1
Dr. Eric Jeltsch F.
6)
T(1) = 1
T(n) = 2T(n-1) + 1, Use Iteration Method.
------------------------------------------------------7) T(1) = 1
T(n) = T(n-1) + 1/n, Use Integration.
------------------------------------------------------8) T(n) = 3T(n/2) + nlogn, Use the Master-Method to find T(n).
Idem for T(n) = T(n/2) + 1/n, T(n) = 2 T(n/2) + n log n, T(n) = 8 T(n/2) +
n2
.
log n
------------------------------------------------------9) T(n) = 2n T(n/2). Find the solution.
------------------------------------------------------10)
n
22 = Ω(n2n) ?, n2n = Ω(2n) ?, 2n = Ω((3/2)n) ?, (3/2)n = Ω(nloglog n) ?, nloglogn = Ω(logn)! ?
------------------------------------------------------11) T(1) = 3
T(n) = 2T(n/2) + 2, n>1
Iteration Method and master Theorem:
------------------------------------------------------12)
T (1) = 2
2
  n   Iteration method:
T (n) =  T   
  2 
Escuela Ingeniería en Computación, Universidad de La Serena.

Documentos relacionados