University of British Columbia
CPSC 420 - Spring 2015
Midterm Examination I
February 04, 2015
Name:
LASTNAME, Firstname(s)
Student Number:
Duration:
90 minutes
Aids allowed: one double-sided, 8.5 11 sheet of notes
Keep the exam booklet closed until the be

Practice Final CPSC 420+500
13 April 2016
1. Indicate whether the following statements are True or False. You do not need to give a proof.
For positive integer n, (n + 1)! O(n!).
For positive f () and positive integer n, f (n) (f (n/2)
For positive f () a

CPSC 420+500
Solution Set 6 Sketches
23 Mar 2016
1. Stephen Cook showed how to take any decision problem in the class NP and its input and
construct (in polynomial time) a Boolean formula that is satisfiable if and only if the input
is a yes-instance of t

CPSC 420+500
W. Evans
Problem Set 5
3 Mar 2016
Due: 16 Mar 2016 at 21:00 (9pm)
Submission Instructions
Handin your solutions using handin. You can write your solutions by hand and scan the pages or
take pictures of them with your phone; or use a word proc

CPSC 420
Solution Set 1 Sketches
19 Jan 2016
1. The fraction of oil in the oil jar equals the fraction of vinegar in the vinegar jar. Whatever
amount of oil ends up in the vinegar jar equals the amount of vinegar that ends up in the oil
jar.
2.
5
(log n)

CPSC 420+500
W. Evans
Problem Set 2
22 Jan 2016
Due: 1 Feb 2016 at 21:00 (9pm)
Submission Instructions
New: Please submit your answer to each problem in a separate pdf file. Handin your
solutions using handin. You can write your solutions by hand and scan

CPSC 420+500
W. Evans
Problem Set 6
17 Mar 2016
Due: 23 Mar 2016 at 21:00 (9pm)
Submission Instructions
Handin your solutions using handin. You can write your solutions by hand and scan the pages or
take pictures of them with your phone; or use a word pro

CPSC 420+500
W. Evans
Problem Set 3
1 Feb 2016
Due: 9 Feb 2016 at 21:00 (9pm)
Submission Instructions
Handin your solutions using handin. You can write your solutions by hand and scan the pages or
take pictures of them with your phone; or use a word proce

CPSC 420+500
W. Evans
Problem Set 4
10 Feb 2016
Due: 24 Feb 2016 at 21:00 (9pm)
Submission Instructions
Handin your solutions using handin. You can write your solutions by hand and scan the pages or
take pictures of them with your phone; or use a word pro

CPSC 420+500
W. Evans
Problem Set 1
7 Jan 2016
Due: 19 Jan 2016 at 21.00 (9pm)
Submission Instructions
Handin your solutions using handin. You can write your solutions by hand and scan the pages or
take pictures of them with your phone; or use a word proc

CPSC 420+500
Solution Set 4 Sketches
24 Feb 2016
1. (a) Let f be a flow with size(f ) = 1. The flow f is composed of a number of simple paths
P
where
P
P1k, P2 , . . . , Pk (k 1) from s to t carrying flows of size a1 , a2 , . . . , ak respectively,
a
=
1.

Practice Final CPSC 420+500
13 April 2016
1. Indicate whether the following statements are True or False. You do not need to give a proof.
False For positive integer n, (n + 1)! O(n!).
False For positive f () and positive integer n, f (n) (f (n/2)
False F

CPSC 420+500
1.
Solution Set 5 Sketches
2
3
2
2
1
1
16 Mar 2016
2
A maximum weight independent set in a path of n vertices either contains the last vertex
vn or not. If it contains vn then it also contains a maximum weight independent set from
the vertic

1. On-Line Convex Hull
The idea is to add each new point to the current convex hull that we have computed so far
in time proportional to the size of the current hull. For the first few points, each convex
hull is easy to compute: it is either a point or a

Assignment 4: Sample solutions and comments
1. (a) Consider the following algorithm:
Algorithm 1 Incremental Un-Dominated(S)
1: while |S| > 0 do
2:
nd the point p S with maximum x-coordinate (breaking a tie by
choosing the point with maximum y-coordinate)

Assignment 1: Sample solutions and comments
1. Hopefully everyone understood this question, so no further explanation is
needed.
2. (a) Despite the hint, many people seemed somewhat confused about how
to structure the induction argument. The basis of the

University of British Columbia
CPSC 420 - Spring 2015
Midterm Examination II
March 04, 2015
Name:
LASTNAME, Firstname(s)
Student Number:
Duration:
90 minutes
Aids allowed: one double-sided, 8.5 11 sheet of handwritten notes
Keep the exam booklet closed un

Assignment 2: Sample solutions and comments
1. Consider the following algorithm:
Algorithm 1 UnaryMax(S)
1: randomly reorder the elements x1 , x2 , . . . , xn of S
2: determine the value of x1 (by binary search) and assign this value to M AX
3: for i = 2,

Assignment 3: Sample solutions and comments
1. (a) In general the cost of a divide-and-conquer algorithm can be expressed
as the sum of three terms: the split cost (the cost of splitting the
problem into subproblems), the recursive cost (the cost of recur

Assignment 6/7: Sample Solutions
[t]
[t]
1. (a) By denition ai,j , the i, j-th entry of A[t] , satises ai,j = 1, if there is
[t]
a path of exactly t edges from vertex vi to vertex vj in g (and ai,j = 0,
t
t
otherwise). Similarly, ai,j , the i, j-th entry

Assignment 5: Sample Solutions
1. (a) The following procedure searches for key x in a B-S array A of size
2k+1 1:
Algorithm 1 MEMBER(x, A, k)
1: f ound F ALSE; j k
2: while j 0 and not(f ound) do
3:
if A[2j ] = then
4:
binary search in A[2j , 2j+1 1] for

University of British Columbia
Department of Computer Science
PRACTICE MIDTERM EXAMINATION IN CPSC 420+500
SPRING 2016
Professor William Evans
This is a closed book examination. You have 90 minutes. Do all 4 problems. (Actually, I gave you
one extra pract

CPSC 420+500
Solution Set 7 Sketches
6 Apr 2016
1. Let Ci = (Vi , Ei ) be the cycle containing i vertices created by the closest-point heuristic. The
heuristic starts by creating C1 and then adds a vertex to create C2 , etc. We show that the
length of the

CPSC 420+500
1.
min z
z axi + byi c
z (axi + byi c)
Solution Set 3 Sketches
10 Feb 2016
1ik
1ik
with variables a, b, c, and z. This doesnt really solve the problem since a = b = c = 0 (with
z = 0) is an optimal solution but its not a line. (What is it?) W

CPSC 420+500
W. Evans
Problem Set 7
29 Mar 2016
Due: 6 Apr 2016 at 21:00 (9pm)
Submission Instructions
Handin your solutions using handin. You can write your solutions by hand and scan the pages or
take pictures of them with your phone; or use a word proc

CPSC 420+500
Solution Set 2 Sketches
1 Feb 2016
1. (a) Step 1 can be accomplished in O(n) time, by looking through all of the points and
updating the maximum and minimum points. Step 2/3 take O(1) time.
Now, in the while loop, we only push new segments on