100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Summary

Summary Algoritme en datastructuren Samenvating + Oefentoets

Rating
5.0
(1)
Sold
2
Pages
35
Uploaded on
20-03-2019
Written in
2018/2019

Samenvatting van de hoorcollege slides met aanvullingen uit het boek, inclusief oefententamen met uitwerking

Institution
Course











Whoops! We can’t load your doc right now. Try again or contact support.

Connected book

Written for

Institution
Study
Course

Document information

Summarized whole book?
Unknown
Uploaded on
March 20, 2019
File latest updated on
March 21, 2019
Number of pages
35
Written in
2018/2019
Type
Summary

Subjects

Content preview

Hanzehogeschool Groningen



Algoritme en
datastructuren
Samenvatting




M. Scholten
11-3-2019

,Inhoud
Recursion ......................................................................................................................................................... 2
The big O notation........................................................................................................................................... 3
Sorting ............................................................................................................................................................. 7
Insertion sort ............................................................................................................................................... 7
Bubble sort .................................................................................................................................................. 8
Merge sort ................................................................................................................................................... 9
Quick sort .................................................................................................................................................. 10
Lists, Stacks & Queues ................................................................................................................................... 11
Lists ............................................................................................................................................................ 11
Stack .......................................................................................................................................................... 12
Queues ...................................................................................................................................................... 12
Binary Search Tree ........................................................................................................................................ 12
AVL Trees ....................................................................................................................................................... 13
Hashing .......................................................................................................................................................... 16
Set.............................................................................................................................................................. 16
Map ........................................................................................................................................................... 16
Hashing ...................................................................................................................................................... 17
Graphs ........................................................................................................................................................... 18
Basics ......................................................................................................................................................... 18
Graph Traversals........................................................................................................................................ 19
Backtracking .................................................................................................................................................. 20
Dynamic Programming .................................................................................................................................. 21
Dijkstra’s Algorithm ....................................................................................................................................... 22
A* Algorithm ................................................................................................................................................. 23
Prim’s Algorithm............................................................................................................................................ 24
Practice Exam ................................................................................................................................................ 25




1

,Recursion
Recursion is a method of solving a problem where the solution depends on solutions to smaller instances
of the same problem. So, the tactic is to divide a problem into subproblems of the same type as the
original, solve all the subproblems and combine the results. Recursion is essentially repetition without a
loop.
All recursive methods have the following characteristics:
- One or more base cases are used to stop recursion (a base case is the simplest case)
- Every recursive call reduces the original problem, bringing it increasingly closer to a base case
until it becomes that case.
Let’s consider a simple problem of printing a message for n times. You can break the problem into two
subproblems: one is to print the message one time and the other is to print the message for n-1 times.
The second problem is the same as the original problem with a smaller size. The base case for the
problem is n==0. You can solve this problem using recursion as follows:
nPrintln(“Welcome”, 5);


public static void nPrintln(String message, int times) {
if (times >= 1) {
System.out.println(message);
nPrintln(message, times - 1);
} // The base case is times == 0
}
Recursion bears substantial overhead. Each time the program calls a method, the system must assign
space for all the method’s local variables and parameters. This can consume considerable memory and
requires extra time to manage the additional space.
Recursion is good for solving the problems that are inherently recursive




2

, The big O notation
Most algorithms transform input object into output object where the running time typically grows with
the input size. The average case time is difficult to determine, so we focus on the worst-case running
time. The worst-case running time is easier to analyze and is crucial to applications such as games, finance
and robotics
Experimental studies:
- Write a program implementing the algorithm
- Run the program with inputs of varying size and composition
- Use a method like System.currentTimeMillis() to get an accurate measure of the actual running
time
- Plot the results
Limitations of Experiments
- It is necessary to implement the algorithm, which may be difficult
- Results may not be indicative of the running time on other inputs which are not included in the
experiment
- To compare two algorithms, the same hardware and software environments must be used
Theoretical Analysis
- Uses a high-level description of the algorithm instead of an implementation (pseudo code)
- Characterizes running time as a function of the input size, n.
- Considers all possible inputs
- Allows us to evaluate the speed of an algorithm independent of the hardware/software
Pseudocode
- High-level description of an algorithm
- More structured than English prose, but less detailed than a program
- Preferred notation for describing algorithms
- Hides program design issues
- Example: find max element of an array:
Algorithm arrayMax(A, n)
Input array A of n integers
Output maximum element of A
currentMax  A[0]
for i  1 to n − 1 do
if A[i]  currentMax then
currentMax  A[i]
return currentMax




3

Reviews from verified buyers

Showing all reviews
2 year ago

5.0

1 reviews

5
1
4
0
3
0
2
0
1
0
Trustworthy reviews on Stuvia

All reviews are made by real Stuvia users after verified purchases.

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.
marnickscholten Hanzehogeschool Groningen
Follow You need to be logged in order to follow users or courses
Sold
12
Member since
6 year
Number of followers
12
Documents
2
Last sold
2 year ago

4.7

3 reviews

5
2
4
1
3
0
2
0
1
0

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