Final Exam
Final Exam
Final Exam
• Do not open this exam booklet until you are directed to do so. Read all the instructions first.
• The exam contains 6 problems, each with multiple parts. You have 180 minutes to earn 180
points.
• This exam booklet contains 17 pages, including this one, and two sheets of scratch paper
which can be detached.
′′
• This exam is closed book. You may use 3 double-sided Letter (8 12 × 11′′ ) or A4 crib sheets.
No calculators or programmable devices are permitted. Cell phones must be put away.
• Write your solutions in the space provided. If you run out of space, continue your answer on
the back of the same sheet and make a notation on the front of the sheet.
• Do not waste time deriving facts that we have studied. It is sufficient to cite known results.
• Do not spend too much time on any one problem. Generally, a problem’s point value is an
indication of how many minutes to spend on it.
• Show your work, as partial credit will be given. You will be graded not only on the correct-
ness of your answer, but also on the clarity with which you express it. Please be neat.
• Good luck!
1 True or False 40 8
2 Short Answer 20 4
3 Estate Showing 30 3
5 Well-Separated Clusters 30 3
Total 180
Name:
6.046J/18.410J Final Exam Name 2
(a) T F If a problem has an algorithm that is correct for 2/3 fraction of the inputs, then it
also has an algorithm that is correct for 99.9% of the inputs.
(b) T F If a problem has a randomized algorithm that runs in time t and returns the correct
answer with probability at least 2/3, then the problem also has a deterministic
algorithm that runs in time t and always returns the correct answer.
6.046J/18.410J Final Exam Name 3
(c) T F A perfect hash table that is already built requires 2 hash functions, one for the
first level hash, and another for the second level hash.
(e) T F If we use van Emde Boas (vEB) to sort n elements, it is possible to achieve
O(n lg lg n) running time. Thus, whenever we need to use traditional O(n lg n)
sorting, we can replace it with vEB sort and achieve a better asymptotic running
time (ignore setup time).
6.046J/18.410J Final Exam Name 4
(f) T F The “union-by-rank” and “path-compression” heuristics do not improve the run-
ning time of M AKE -S ET in the union-find data structure.
(g) T F There is an NP-hard problem with a known polynomial time randomized algo-
rithm that returns the correct answer with probability 2/3 on all inputs.
(a) Recall the forest-of-trees solution to the disjoint-set problem. Suppose that the only
heuristic we use is a variant of the union-by-rank heuristic: when merging two roots
u and v, we compare the number of descendants (rather than the rank), and make u a
child of v if and only if u has fewer descendants. Is this asymptotically worse than the
original union-by-rank heuristic? Explain why or why not.
(b) Suppose we apply Huffman coding to an alphabet of size 4, and the resulting tree is
a perfectly balanced binary tree (one root with two children, each of which has two
children of its own). Find the maximum frequency of any letter.
6.046J/18.410J Final Exam Name 6
(c) In lecture, we saw min-radius clustering, in which the goal was to pick a subset of k
points such that each point formed the center of a cluster of radius r. Suppose instead
that the center of the cluster can be a point not in the original set.
Give an example set of points where it is possible to find k clusters of radius r centered
around arbitrary points, but impossible to find k clusters of radius r centered around
points in the set.
(d) Consider the following algorithm, which is intended to compute the shortest distance
among a collection of points in the plane:
(a) Trip tells you his idea: find all-pairs shortest paths on G, and then try to select k of
those shortest paths ai ❀ bj such that all k paths start and end at different vertices and
no two paths share any edges.
Give a graph where there exists a set of paths satisfying the requirements, but where
Trip’s strategy won’t find it.
6.046J/18.410J Final Exam Name 8
(b) Rather than using shortest paths, you think that perhaps you can formulate this as a
flow problem. Find an algorithm to find k paths ai ❀ bj that start and end at different
vertices and that share no edges, and briefly justify the correctness and running time
of your algorithm.
6.046J/18.410J Final Exam Name 9
(c) Trip, after trying out the paths found by your algorithm, realizes that making sure the k
paths don’t share edges isn’t enough: it’s possible that some paths will share vertices,
and his buyers might run into each other where their paths intersect.
a1 b1 a1 b1
a2 a2
b2 b2
Modify your algorithm to find k paths ai ❀ bj that start and end in different locations,
and that share neither vertices nor edges.
6.046J/18.410J Final Exam Name 10
(a) Give an example where Zelda’s algorithm will not use the optimal number of credit
cards.
(b) Show that Zelda’s algorithm gives a 2-approximation for the number of credit cards.
HINT: Let OP T be the optimal number of credit cards. In order for the algorithm to
add a new credit card j > OP T , it must reach xi such that xi + ′ min L[j ′ ] > ℓ.
j ∈{1,...,OP T }
It will then set L[j] = xi .
6.046J/18.410J Final Exam Name 11
(c) Show that minimizing the number of credit cards used is NP-hard.
6.046J/18.410J Final Exam Name 12
Your goal is to use this information to construct an algorithm for computing the number of clusters.
(a) Give an algorithm that takes as input r and ǫ, and outputs the exact value of k.
6.046J/18.410J Final Exam Name 13
(b) Given a particular cluster Ci , if you sample t points uniformly at random (with re-
placement), give an upper bound in terms of ǫ for the probability that none of these
points are in Ci .
(c) Give a sublinear-time algorithm that takes as input r and ǫ, and outputs a number of
clusters k that is correct with probability at least 2/3.
6.046J/18.410J Final Exam Name 14
(b) Give a set of microscopes and an algorithm to find the bacterium with total cost
O(n lg lg n).
SCRATCH PAPER
SCRATCH PAPER
MIT OpenCourseWare
http://ocw.mit.edu
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.