Labbar är i E:Hacke och i Discord.
todo:readingadvice.pdf
Quiz: You have points in a plane and want to find a pair of points with minimal distance. How can you do that?
You could use two for-loops. For each point find the distance to every other point. O(n**2). This is efficient according to theory. It is too slow in practice for large number of points. If 10**9 points it would take years.
If dividing the field into subfields it would take seconds instead of years (Divide and conquer).
Frågor kring rimlighet eller vilka algoritmer man kan använda för att lösa problemen. Fråga att förklara för en 4a åring kring hur man gör något. Man får inte använda svåra ord från denna kursen då utan bara enkla ord.
Example
If U contains two pairs who want to split U is called an unstable matching. A stable matching is a perfect matching with no unstable pairs.
How does it work? - How do we find a stable matching?
procedure GS(S, C)
S is a set of n students and C is a set of n companies , add each studnet s to al list p.
while p!= null {
s <- take out the first element from p
c <- the companies prefers the most and s has not yet applied
to
if c has no student
(s, c) becomes a pair
else if c prefers s over its current student sc then
remove the pair sc, c
s,c becomes a pair instead
else
add it into the list again
}
Facts
Is Gale-Shapley fair? No the company will always receive the worst possible student. It does however find the best company for the students.