Matchings
Saad Mneimneh
1
Stable matching
Consider n men and n women. A matching is a one to one correspondence
between the men and the women. In nding a matching, however, we would
like to respect the preferences of men and women as much as possible. To
Network ows and shortest paths
Saad Mneimneh
1
Introduction
Let G = (V, E ) be a directed graph with two special vertices: a source s and
a sink t. Every edge (u, v ) has a capacity cap(u, v ) 0. For convenience, we
dene cap(u, v ) = 0 if (u, v ) in not a
Depth rst search with applications
Saad Mneimneh
1
Introduction
Given a graph G = (V, E ) and a vertex u V , we would like to explore every
vertex (and every edge) reachable from u. Let n = |V | and m = |E |. The
graph may be directed or undirected. We wi
Linear programming
Saad Mneimneh
1
Introduction
Consider the following problem:
maximize x1 + x2
subject to 4x1 x2 8
2x1 + x2 10
5x1 2x2 2
x1 , x2 0
The feasible solution is a point (x1 , x2 ) that lies within the region dened by
the lines 4x1 x2 = 8, 2x1
Making faster multiplications
Saad Mneimneh
1
A simple divide-and-conquer inspired by Gauss
Consider the multiplication of two complex numbers:
(a + bi)(c + di) = ac + (bc + ad)i bd
which involves four multiplications: ac, bc, ad, and bd. Gauss observed t
Generating large primes
Saad Mneimneh
1
A simple paradigm
Generating a large prime is an important step in the RSA algorithm. We can
generate a large prime by repeatedly selecting a large random integer and testing
it for primality. We stop when a prime n
The Euclidean algorithm
Saad Mneimneh
1
The greatest common divisor
Consider two positive integers a0 > a1 . The greatest common divisor of a0 and
a1 , denoted gcd(a0 , a1 ) is the largest positive integer g such that g |a0 and g |a1 ,
i.e. g divides both