CMPT 705 Design and Analysis of Algorithms
Outline Solutions to Exercises on Flow Networks and NP-Completeness
1. We say that a bipartite graph G = (V, E), where V = L R is the bipartition, is d-regular if every vertex
v V has degree exactly d. Every d-re

CMPT 705 Design and Analysis of Algorithms
Outline Solutions to Exercises on Dynamic Programming
1. The residents of the underground city of Zion defend themselves through a combination of kung fu, heavy
artillery, and efcient algorithms. Recently they ha

CMPT 705 Design and Analysis of Algorithms
Outline Solutions to Midterm
1. Explain how to nd a negative cycle in an edge weighted graph.
Lecture 6.
2. Describe Prims or Kruskals algorithm (or both).
See Lectures 3.
3. You were asked to solve at home the f

CMPT 705 Design and Analysis of Algorithms
Outline Solutions to Exercises on Approximation Algorithms
1. Recall that in the basic Load Balancing problem we are interested in placing jobs on machines so as
to minimize the makespan the maximum load of any o

Algorithms More Randomization
22-1
More Randomization
Design and Analysis of Algorithms
Andrei Bulatov
21-2
Algorithms Randomization
Contention Resolution in a Distributed System
Contention resolution
Instance
Given n processes P ,K, Pn , each competing f

Algorithms Chernoff Bound
23-1
Coupon Collector and
MAXSAT
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms More Randomization
Coupon Collector
Coupon collector. Each box of cereal contains a coupon. There are n
different types of coupons. Assu

FPTAS
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms More Approximation II
Polynomial Time Approximation Scheme
PTAS. An approximation algorithm for any constant relative error
> 0.
Load balancing. [Hochbaum-Shmoys 1987]
Euclidean TSP. [A

Closest Pair
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Closest Pair
Closest Pair: The Problem
The Closest Pair Problem
Instance:
n points in the plane
Objective:
Find a pair of points that are closest together
min
24-2
Algorithms Closest

Algorithms Randomization
21-1
Randomization
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Randomization
Randomization
Algorithmic design patterns.
Greed.
Divide-and-conquer.
Dynamic programming.
Network flow.
in practice, access to a pseudo-

Algorithms Primes
25-1
Primes
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Primes
The Problem
The Primes problem
Instance:
A positive integer k.
Objective:
Is k prime?
The complement of Primes, the Composite problem, belongs to NP.
Therefor

Algorithms NP-Completeness II
18-1
NP-Completeness II
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms NP-Completeness II
Traveling Salesperson Problem
The Traveling Salesperson Problem
Instance:
A set of n cities, a pairwise distance function

Algorithms PSPACE
19-1
PSPACE
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms PSPACE
19-2
Games
Geography.
Amy names capital city c of country she is in. Bob names a capital
city c' that starts with the letter on which c ends. Amy and Bob
repe

Algorithms NP-Completeness
17-1
NP and NP-Completeness
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms NP-Completeness
Efficient Certification
By a solution of a decision problem X we understand a certificate
witnessing that an instance is a y

Algorithms Airline Scheduling
Airline Scheduling
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Airline Scheduling
11-2
The Problem
An airline carrier wants to serve certain set of flights
Example:
Boston (6 am) - Washington DC (7 am), San Fr

Algorithms Sequence Alignment
Sequence Alignment
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Sequence Alignment
The Sequence Alignment Problem
Question:
How similar two words are?
Say ocurrance and occurrence
They are similar, because one

Algorithms Polynomial Time Reductions
16-1
Poly-Time Reductions
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Polynomial Time Reductions
Poly-Time Reductions
There are 3 types of problems:
easy (polynomial time)
hard (provably super polynomi

Matchings
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Matchings
Matchings
A matching M of a graph G = (V,E) is a set of edges such that every
vertex is incident to at most one edge from M
Bipartite graphs: bipartition X, Y
The Bipartite Ma

Network Flow
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Network Flow
Flow Networks
Think of a graph as system of pipes
We use this system to pump water from the source s to sink t
Every pipe/edge has limited capacity
Flow occurs when we p

Algorithms Demands and Bounds
Demands and Bounds
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Demands and Bounds
Demands
In our flow network model there is only 1 source and sink
Can we do something for several sources and sinks?
More gener

Stationary Distribution
Design and Analysis of Algorithms
Andrei Bulatov
34-2
Algorithms Markov Chains
Classification of States
By Pik j we denote the (i,j)-entry of
,
State
is accessible from state
If
is accessible from
and
communicate,
and
if Pik j > 0

Approximation
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Approximation
Approximation Algorithms
Suppose I need to solve an NP-hard problem. What should I do?
Theory says you're unlikely to find a poly-time algorithm.
Must sacrifice one of

CMPT 705
Midterm Test
Some Day, 2016
This is a sample!
Last Name
First Name and Initials
Student No.
NO AIDS allowed. Answer ALL questions on the test paper. Use backs of
sheets for scratch work.
Total Marks: 100
1. What problem does Dijkstras algorithm s

Greedy Algorithms
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Introduction
Graph Reminder
Vertices and edges
Nodes and arcs
Representation of graphs:
- adjacency matrix
- adjacency lists
Degrees of vertices, indegree, outdegree; regular gr

Divide and Conquer
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Divide and Conquer
Divide and Conquer, MergeSort
Recursive algorithms: Call themselves on subproblem
Divide and Conquer algorithms:
Split a problem into subproblems (divide)
So

Algorithms Disjoint Paths
Disjoint Paths
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Disjoint Paths
13-2
Disjoint Paths Problem
A set of paths are said to be disjoint if they do not have common edges
The Directed Edge-Disjoint Paths Proble

Linear Programming
Duality
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Linear Programming Duality
Linear Programming
Linear Programming
Instance
Objective function
z = c1x1 + c2x2 + . + cnxn
Constraints:
a11x1 + a12x2 + . + a1nxn b1
a21x1

Algorithms Primes
25-1
Primes
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Primes
The Problem
The Primes problem
Instance:
A positive integer k.
Objective:
Is k prime?
The complement of Primes, the Composite problem, belongs to NP.
Therefor

Chapter 1 Introduction
1. Stable matching
So consider a set M = cfw_m1, . . . ,mn of n men, and a set W = cfw_w 1, . . . , wn of n women. Let M W
denote the set of all possible ordered pairs of the form (m, w), where m M and w W.
A matching S is a set of

Linear Programming
Duality
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Linear Programming Duality
Linear Programming
Linear Programming
Instance
Objective function
z = c1x1 + c2x2 + . + cnxn
Constraints:
a11x1 + a12x2 + . + a1nxn b1
a21x1

Linear Programming
Design and Analysis of Algorithms
Andrei Bulatov
30-2
Algorithms Linear Programming
Maximal Flow
u
20
10
s
t
30
10
20
v
Algorithms Linear Programming
Linear Programming
Linear Programming
Instance
Objective function
z = c1x1 + c2x2 + .

CMPT 705 Design and Analysis of Algorithms
Exercises on Flow Networks and NP-completeness. Due: Tuesday,
November 1st (at the beginning of the class)
Reminder: the work you submit must be your own. Any collaboration and consulting outside
resources must b

CMPT 705 Design and Analysis of Algorithms
Exercises on Flow Networks. Due: Tuesday, October 18th (at the
beginning of the class)
Reminder: the work you submit must be your own. Any collaboration and consulting outside
resources must be explicitly mention