Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Samenvatting

Samenvatting van het vak Algoritmiek

Beoordeling
-
Verkocht
4
Pagina's
27
Geüpload op
26-05-2021
Geschreven in
2020/2021

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

Voorbeeld van de inhoud

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 ?

Documentinformatie

Geüpload op
26 mei 2021
Aantal pagina's
27
Geschreven in
2020/2021
Type
SAMENVATTING
€5,58
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
pactasuntservanda Universiteit Utrecht
Bekijk profiel
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
157
Lid sinds
8 jaar
Aantal volgers
137
Documenten
0
Laatst verkocht
1 week geleden

3,3

36 beoordelingen

5
7
4
9
3
11
2
4
1
5

Populaire documenten

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen