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 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

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 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

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

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 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

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

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

Zhilin Zhang
301274831
Q1.
(a) Given a sequence of words W=cfw_abc, d, e, and let the maximal line length of L be 5.
Then the greedy algorithm will produce the following result:
a
e
b
f
c
d
where the sum of the squares of the slacks of all lines is 3 2=9

1. Note that the main challenge of the problem comes from the truth that hospitals want
more than one resident and there is a surplus of medical students. Thus, at any time, a
hospital either has some available positions or is fully filled, while a studen

Zhilin Zhang
301274831
Q1.
Case 1:
d 1 ( p 1 , p2 )=|x 1x 2|+| y1 y 2|
Algorithm design: a divide and conquer approach is presented as follows:
Setting up the recursion:
1. We sort all the points in P by x-coordinate and again by y-coordinate, producing l

Zhilin Zhang
1. (a)
301274831
Prove that, for any connected graph G, the associated graph
H
is also
connected
ProofTo prove (a), we first prove the following fact:
Statement 1: Let
T =(V , F) and T ' =(V , F ' ) be two spanning trees of G, where
|FF'|=|F

Zhilin Zhang
301274831
Q1. To prove that DOMINATING SET is NP-complete,
1) We first need to prove that DOMINATING SET is NP. In other words, we need to prove
that given a set S, we can verify it is a dominating set in polynomial time. The proof is
straigh

3. Let G = (V, E) be a directed graph with nodes v1, . . . , UH. We say that G is
an ordered graph if it has the following properties.
(i) Each edge goes from a node with a lower index to a node with a higher
index. That is, every directed edge has the fo

20. Every September, somewhere in a far-away mountainous part of the
world, the county highway crews get together and decide which roads to
keep clear through the coming winter. There are n towns in this county,
and the road system can be viewed as a (con

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

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

Poularikas A. D. Calculus
The Handbook of Formulas and Tables for Signal Processing.
Ed. Alexander D. Poularikas
Boca Raton: CRC Press LLC,1999
1999 by CRC Press LLC
45
Calculus
45.1 Derivatives
45.2 Integration
45.3 Integrals
45.1 *Derivatives
In the fo

Poularikas A. D. Laplace Transforms
The Handbook of Formulas and Tables for Signal Processing.
Ed. Alexander D. Poularikas
Boca Raton: CRC Press LLC,1999
2
Laplace Transforms
2.1
2.2
2.3
2.4
Definitions and Laplace Transform Formulae
Properties
Inverse La

Poularikas A. D. Fourier Transform
The Handbook of Formulas and Tables for Signal Processing.
Ed. Alexander D. Poularikas
Boca Raton: CRC Press LLC, 1999
3
Fourier Transform
3.1
One-Dimensional Fourier Transform
Definitions Properties Tables
3.2
Two-Dimen

Poularikas A. D. Distributions, Delta Function
The Handbook of Formulas and Tables for Signal Processing.
Ed. Alexander D. Poularikas
Boca Raton: CRC Press LLC, 1999
5
Distributions, Delta
Function
5.1 Test Function
5.2 Distributions
5.3 One-Dimensional

Poularikas A. D. Algebra
The Handbook of Formulas and Tables for Signal Processing.
Ed. Alexander D. Poularikas
Boca Raton: CRC Press LLC,1999
1999 by CRC Press LLC
44
Algebra
44.1
44.2
44.3
44.4
44.5
44.6
44.7
44.1
Factors and Expansions
Powers and Root

Poularikas A. D. Fourier Series
The Handbook of Formulas and Tables for Signal Processing.
Ed. Alexander D. Poularikas
Boca Raton: CRC Press LLC, 1999
1
Fourier Series
1.1 Definitions and Series Formulas
1.2 Orthogonal Systems and Fourier Series
1.3 Decre

Poularikas A. D. Signals and Their Characterization
The Handbook of Formulas and Tables for Signal Processing.
Ed. Alexander D. Poularikas
Boca Raton: CRC Press LLC,1999
10
Signals and Their
Characterization
10.1 Common One-Dimensional Continuous Signals

Dynamic Programming
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Dynamic Programming
Knapsack
The Knapsack Problem
Instance:
A set of n objects, each of which has a positive integer value vi
and a positive integer weight wi . A weight limit

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

Spanning Tree
Design and Analysis of Algorithms
Andrei Bulatov
Algorithms Spanning Tree
The Minimum Spanning Tree Problem
Let G = (V,E) be a connected undirected graph
A subset T E is called a spanning tree of G if (V,T) is a tree
If every edge of G has a

CMPT 705 Design and Analysis of Algorithms
Outline Solutions to Exercises on Graphs and Greedy Algorithms
1. Consider the problem of making change for n cents using the fewest number of coins. Assume each coins
value is an integer.
(a) Describe a greedy a

CMPT 705 Design and Analysis of Algorithms
Outline Solutions to Exercises on Divide and Conquer
1. You are interested in analyzing some hard-to-obtain data from two separate databases. Each database
contains n numerical values so there are 2n values total