Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Resumen

Samenvatting van het vak Algoritmiek

Puntuación
-
Vendido
4
Páginas
27
Subido en
26-05-2021
Escrito en
2020/2021

Samenvatting van het vak Algoritmiek aan de Universiteit Utrecht, gebaseerd op de hoorcolleges.

Institución
Grado

Vista previa del contenido

Algorithms
We have to learn to know, apply and analyse algorithmic techniques.




Recap: Asymptotic notation

The formal definitions


is asymptotically at most .


is asymptotically at least .


is asymptotically equal to .


is asymptotically strictly smaller than .


is asymptotically strictly larger than .



Recurrent relations can be solved using substitution, inspection of the recursion tree or the master theorem.



Using substitutions
Given a recurrent relation , make a guess what the solution could be.
Prove using induction (prove the base case, set up the induction hypothesis and prove the step) that the guess is
correct.



Master Theorem
The master theorem provides a solution to recurrent relations of the form for constants
and and asymptotically positive.


Is exponential? Then surely you will get .
Write as .
Calculate .


Case 1: If , then .
Case 2: If and , then .
Case 3: If , then .




Algorithmic techniques
Some problems one might get faced to:

, Optimization problem: Find the best/optimal solution for a certain problem.
Construction problem: In which way can one solve the problem.
Decision problem: Is it possible to solve the problem?




Divide and conquer
Divide-and-conquer is a pattern to specify how to break up a computation, until the problem becomes simple enough to be
solved directly, and then combine. It involves three steps:


1. Divide: split in subproblems (which are smaller instances of the same problem).

2. Conquer: solve the subproblems recursively.

Base case: when the subproblem is small enough, just solve it in a straightforward manner.
3. Combine: combine the subsolutions to form the solution for the original problem.


MergeSort for example (as seen in the course datastructures) closely follows this paradigm.


A recurrence for the running time of a divide-and-conquer algorithm falls out from the three steps basic paradigm, in which
if the problem size is small enough, we say for some constant , the straightforward solution takes .




( and denote time to divide and combine respectively.)



Correctness: Induction
Prove that the base case is correct. Then the induction hypothesis is: the algorithm works for all smaller input.


Induction step:


The sub-problems have smaller inputs and hence are being solved correctly.
Sub-solutions are being combined correctly.




Dynamic programming
Helps to prevent recurring calculations, especially with recurrent relations. Idea is not to calculate something for the
second time. One could describe DP as "careful" brute-force. Two possible implementations:


Memoization: Technique of caching and reusing previously computed results.
"Classical" DP / bottom-up DP: Filling the entries of the cache/array, until the target value has been reached.


You typically get polynomial time.

, Example: Fibonacci
The "naive" recursive approach to calculate a Fibonacci number, which is



fib(n):

if n "== 0: return 0
if n "== 1: return 1
else: return fib(n-1) + fib(n-2)




has recurrent relation .


Instead we could use a memoized DP algorithm, which looks like the following pseudo code:



memo = {} "/* Start with empty dictionary "*/

fib(n):
if n in memo: return memo[n]
if n "== 0: f = 0
if n "== 1: f = 1

else: f = fib(n-1) + fib(n-2)
memo[n] = f
return f




For all , fib(k) only recurses the first time it's called.



Algorithm design
Identify the sequence of problems. Identify one last choice, the top-choice, which leads to a splitting in one or more
subproblems. You show that the optimal solution is build out of the solutions of one or more subproblems.



Optimality principle
The optimality principle is the basic principle of DP. We should show that the optimal subproblem will be used for the total
problem and thus may be used to find the final solution.


For every option for the top-choice, we should look at which subproblem's solution will be part of the total problem
and why this is the case.



Example: Knapsack problem
One has product with value and weight , and has a maximum weight . What's the subset of product with highest
total value and maximum weight ?

Escuela, estudio y materia

Institución
Estudio
Grado

Información del documento

Subido en
26 de mayo de 2021
Número de páginas
27
Escrito en
2020/2021
Tipo
RESUMEN

Temas

$6.59
Accede al documento completo:

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
pactasuntservanda Universiteit Utrecht
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
157
Miembro desde
8 año
Número de seguidores
137
Documentos
0
Última venta
1 semana hace

3.3

36 reseñas

5
7
4
9
3
11
2
4
1
5

Documentos populares

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes