Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

Summary of the Algorithm course

Rating
-
Sold
4
Pages
27
Uploaded on
26-05-2021
Written in
2020/2021

Summary of the course Algorithmics at Utrecht University, based on the lectures.

Institution
Course

Content preview

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 ?

Written for

Institution
Study
Course

Document information

Uploaded on
May 26, 2021
Number of pages
27
Written in
2020/2021
Type
SUMMARY

Subjects

$6.59
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
pactasuntservanda Universiteit Utrecht
Follow You need to be logged in order to follow users or courses
Sold
157
Member since
8 year
Number of followers
137
Documents
0
Last sold
1 week ago

3.3

36 reviews

5
7
4
9
3
11
2
4
1
5

Trending documents

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions