2019 Spring Final
2019 Spring Final
Final
Name:
SID:
Exam Room:
Wheeler 150 Haas Faculty Wing F295 Lewis 100 McCone 141 Evans 100
Wozniak Lounge other
Please color the checkbox completely. Do not just tick or cross the box.
Rules and Guidelines
• The exam is out of 170 points and will last 170 minutes. Roughly, one should expect to spend a
minute for a point.
• Answer all questions. Read them carefully first. Not all parts of a problem are weighted equally.
Discussion Section
Which of these do you consider to be your primary discussion section(s)? Feel free to choose multiple, or
to select the last option if you do not attend a section. Please color the checkbox completely. Do not just
tick or cross the boxes.
2
SID: Final P. Raghavendra & L. Trevisan
Consider a zero-sum game given by the following matrix (indicating the payoffs to the row player). Here
the row player is trying to maximize their payoff given by the following matrix.
C1 C2 C3
R1 5 3 6
R2 3 2 7
R3 −1 4 −1
Assuming the row-player goes first, write a linear program to find their optimal strategy.
3
Final P. Raghavendra & L. Trevisan
4
SID: Final P. Raghavendra & L. Trevisan
What is the runtime of the following piece of code? Write the recurrence.
Function what(n) {
what(n/2)
what(n/2)
k=n
While (k > 1) {
for i = 1, 2, 3, ..., k {
for j = 1, 2, 3, ..., 2k {
print BLAH
}
}
k = k/4
}
what(n/2)
what(n/2)
}
1. Recurrence Relation
2. Runtime =
5
Final P. Raghavendra & L. Trevisan
Here is the state of the count-min sketch data structure after it has processed a stream of items.
Hash function h1 10 5 3 2 17 1 1 1
Hash function h2 10 6 2 4 6 4 4 4
Hash function h3 13 3 3 6 1 4 4 4A 6
Hash function h4 1 2 3 4 5 6 9 10
For an element A, let trueCount( A) denote the total number of occurrences of A in the stream, and let
estimate( A) denote the estimate of the number of occurrences of A as per the count-min data structure.
4. For two elements A and B, what is the maximum possible value of trueCount( A) + trueCount( B)?
6
SID: Final P. Raghavendra & L. Trevisan
7
Final P. Raghavendra & L. Trevisan
Every network with integer edge capacities has a maximum flow where the amount of flow on each edge
is an integer. Briefly justify.
5 MinCut (4 points)
Let G = (V, E) be a network with source s and sink t. Note that G may have more than one minimum s-t cut
and more than one maximum s-t flow.
For each of the following, let B be the value of the maximum s-t flow of G. Fill the appropriate circle in each
of following cases.
1. Let e be an edge across a minimum s-t cut. Suppose we decrement the capacity of edge e by 1, what is
the value of the maximum s-t flow in the resulting network?
e B−1
e B
e Depends on the network.
2. Let e be an edge on one of the maximum s-t flows. Suppose we decrement the capacity of edge e by
1, what is the value of the maximum flow in the new network?
e B−1
e B
e Depends on the network.
8
SID: Final P. Raghavendra & L. Trevisan
A dynamic programming algorithm has inputs X [1, . . . , n] and Y [1, . . . , n], subproblems E[i, j] for all i, j ∈
{1, . . . , n}, and the following recurrence relation,
E[i − 1, j − 1] + 1
if X [i ] = Y [ j − 1]
E[i, j] = min E[i − 2, d j/2e] + 3 if X [i ] = Y [ j]
E[i − 1, j + 1] + 1 if X [i + 1] = Y [ j + 5]
1. Fill in the blanks in the following pseudocode for the DP algorithm. (It is OK for the code to go out of
bounds on E. In other words, assume that E[i, j] is well-defined and already computed correctly for i,
j in {−2, −1, 0, n + 1, n + 2})
for from 1 to n do {
for from 1 to n do {
E[i − 1, j − 1] + 1
if X [i ] = Y [ j − 1]
E[i, j] = min E[i − 2, j/2] + 3 if X[i] = Y[j]
E[i − 1, j + 1] + 1 if X[i + 1] = Y[j + 5]
}
}
2. Suppose our goal is to compute E[n, n] in polynomial time. What is the smallest memory with which
you can implement the above algorithm?
9
Final P. Raghavendra & L. Trevisan
1. There is a reduction from Independent Set to the Longest Increasing Subsequence problem.
hT hF hP = NP hP 6= NP
hT hF hP = NP hP 6= NP
hT hF hP = NP hP 6= NP
hT hF hP = NP hP 6= NP
10
SID: Final P. Raghavendra & L. Trevisan
hTrue hFalse
2. For every directed graph, there exists a starting point v, such that calling the explore(v) routine in DFS
will visit every node in the graph.
hTrue hFalse
3. For every directed graph and for each SCC in the graph, there exists a starting point v, such that
calling the explore(v) routine will visit every node in that SCC of the graph.
hTrue hFalse
4. For a graph G, there is always some MST of G that does not contain the heaviest edge.
hTrue hFalse
5. Suppose u, v are children of the root in a BFS search tree of a connected undirected graph. Then
deleting the root will always disconnect u and v in the original graph.
hTrue hFalse
6. Suppose u, v are children of the root in a DFS search tree of a connected undirected graph. Then
deleting the root will always disconnect u and v in the original graph.
hTrue hFalse
11
Final P. Raghavendra & L. Trevisan
7. If there is a polynomial time algorithm for 3-SAT then there is a polynomial time algorithm to factor
n bit numbers.
hTrue hFalse
12
SID: Final P. Raghavendra & L. Trevisan
When asked for a bound, always give the tightest exact bound possible, not an
asymptotic one. Some questions have choices in parentheses after the answer box.
1. Dr. Hurry is an impatient man. He is reading the weights on the edges of a graph G one at a time.
After reading just k edges, Dr. Hurry exclaims that an edge e is not part of an MST of G. What is the
smallest possible value of k?
2. Let us suppose we execute the Follow the regularized leader (FTRL) algorithm over convex set [−1, 1],
with regularizer R( x ) = x2 . Suppose the cost functions in first three rounds are f 1 ( x ) = 1 + x,
f 2 ( x ) = 1 − x and f 3 ( x ) = 1 + x. Then, the value of x suggested by FTRL algorithm for the fourth
3. Setting the regularizer function to be a constant function R( x ) = 10 in any FTRL algorithm, we recover
the algorithm.
4. If a graph G has some vertex cover of size k, the size of the maximum matching is at most
5. If a graph G has a maximum matching of size k, the size of the minimum vertex cover is at most
13
Final P. Raghavendra & L. Trevisan
7. The greedy algorithm for HornSAT returns the assignment 00011 on a formula Φ with 5 variables.
What is the maximum number of satisfying assignments that formula can have?
8. A directed graph has a cycle if and only if every depth-first search on the graph reveals a
(tree/forward/back/cross) edge.
14
SID: Final P. Raghavendra & L. Trevisan
An instance of TSP consists of n cities and distances d[·, ·] between every pair of cities. The distances may
not satisfy the triangle inequality. A TSP tour is a path that visits every city exactly once.
There are (n − 1)! possible TSP tours in any instance with n cities. Finding the TSP tour that has the smallest
total length among all these (n − 1)! tours is NP-hard. For distances that don’t satisfy the triangle inequality,
there are no approximation algorithms for the problem either.
Let us say that a TSP tour is Better-Than-Most if its cost is smaller than 99% of the (n − 1)! possible TSP
tours.
1. Describe an algorithm that given δ in (0, 1), runs in polynomial-time in n and 1/δ, and outputs some
tour which is a Better-Than-Most TSP tour with probability 1 − δ.
(Hint: Given two tours, comparing their costs takes linear time.)
15
Final P. Raghavendra & L. Trevisan
3. Prove that the algorithm outputs a Better-Than-Most TSP tour with probability at least 1 − δ.
16
SID: Final P. Raghavendra & L. Trevisan
A rectangular city is divided into a grid of m × n blocks. You would like to setup coffee shops so that for
every block in the city, either there is a coffee shop within the block or there is one in a neighboring block.
(There are up to 4 neighboring blocks for every block).
It costs rij to rent space for a coffee shop in block ij.
1. Write an integer linear program to determine which blocks to setup the coffee shops at, so as to
minimize the total rental costs.
17
Final P. Raghavendra & L. Trevisan
2. Solving the linear program gets you a real valued solution. How would you round the LP solution to
obtain an integer solution to the problem? Describe the algorithm in at most two sentences.
18
SID: Final P. Raghavendra & L. Trevisan
Show that the following problems are NP-complete by providing a polynomial-time reduction. You may
assume that the following problems are NP-complete: Rudrata (Hamiltonian) Path, Rudrata (Hamiltonian)
Cycle, Vertex Cover, Independent Set and 3-SAT.
1. Quarter Path
Input: Graph G = (V, E), and vertex s
Solution: There is a path with n/4 edges all of whose vertices are distinct
We will now use a reduction to show that the problem is NP-complete. Fill up the details in the proof below..
as follows ...
19
Final P. Raghavendra & L. Trevisan
20
SID: Final P. Raghavendra & L. Trevisan
1. Describe the main idea behind the algorithm in three to four sentences.
21
Final P. Raghavendra & L. Trevisan
02 12 22
01 11 21
00 10 20
For T days, both Max and Vinay drive from node 00 to node 22.
To cope with the unpredictability of traffic, Vinay builds a time machine and travels forward in time
to determine the traffic on each edge on every day. Using this information, Vinay picks the path that
has the smallest total travel time over T days, and uses the same path each day.
Max wants to use the multiplicative weights update algorithm to pick a path each day. In particular,
Max wants to ensure that the difference between his expected total travel time over T days and Vinay’s
total travel time is at most T/10000. Assume that Max finds out the lengths of all the edges in the
network, even those he did not drive on, at the end of each day.
22
SID: Final P. Raghavendra & L. Trevisan
1. How many experts should Max use in the multiplicative weights algorithm?
3. Given the weights maintained by the algorithm, how does Max pick a route on any given day?
Theorem. Assuming that all losses for the n experts are in the range [0, 4], the worst possible
regret of the multiplicative weights algorithm run for T steps is
√
R T ≤ 8 T ln n
Use the regret bound to show that expected total travel time of Max is not more than T/10000
worse than that of Vinay for large enough T.
23
Final P. Raghavendra & L. Trevisan
24