Homework 2 - Spring 2024
This homework covers the material from lectures 7 to 11
Due date: June 1st, 10pm Waterloo time.
PDF version of Homework 2.
LaTeX template, in case you want to write it in LaTeX.
Required Exercises
Problem 1 - Fingerprinting (20 points)
Consider the problem of deciding whether two integer multisets
You can assume that the multisets
-
Use polynomial identity testing to give a
time algorithm for the problem above. -
Use hashing to give an algorithm which runs in expected
time for the problem above.
Your algorithms for both parts should succeed with probability
Problem 2 - Randomized Matching (10 points)
Given a randomized algorithm
Your algorithm should have success probability
Problem 3 - Sublinear-time Algorithms (15 points)
Sublinear-time algorithms for connectedness in graphs with bounded degree.
Given a graph
For this problem, when proving the correctness of your algorithm, it is ok to show
that if the input graph
Problem 4 - Markov Chains (15 points)
- Show that if a Markov chain with transition matrix
is irreducible and has a state such that , then it is also aperiodic. - Let
be positive integers and consider the Markov chain with state space where are integers, and the following transition mechanism: if the chain is in state at time , then at time it moves to with probability or to with probability .
Show that this Markov chain is irreducible, and show that it is aperiodic if, and only if,
- Consider a chessboard with a lone white king making random (king) moves, meaning that at each move, he picks one of the possible squares to move to, uniformly at random. Is the corresponding Markov chain irreducible and/or aperiodic? If so, what is the stationary distribution?
Problem 5 - Random Walks (10 points)
-
Consider a Markov chain on the vertices of a triangle: the chain moves from a vertex to one of the other two vertices with probability
each. Find the stationary distribution and -mixing time of this Markov chain. Also, find the probability that the chain is at the starting vertex after steps, for . -
Suppose that we alter the transition probabilities of the Markov chain in the previous question as follows:
Find the stationary distribution and the -mixing time of this Markov chain. Also, find the probability that the chain is at the starting vertex after steps, for .
Problem 6 - Linear Programming (15 points)
Let
Problem 7 - LP Duality (15 points)
For a directed graph
Give the dual of this LP and explain how to interpret the dual LP as a minimum cut problem.
Practice Problems
You are not required to submit the solution to these problems, but highly encouraged to attempt them for your own knowledge sake. :)
Problem 1 - Matching
Let
Hint: you can use the fact that the rank of
Problem 2 - Probability Amplification
In the distinct element algorithm we saw in lecture, we showed that with probability at least
This technique of amplifying the success probability is very general and useful when one would like to have an algorithm with arbitrarily high success rate, given only an algorithm with success probability being a constant strictly greater than 1/2.
Problem 3 - Karger’s Algorithm
One advantage of Karger’s random contraction algorithm for the minimum cut problem
is that it can be used to output all minimum cuts. In this question, we assume Karger’s algorithm
as a black box, which when given a graph
Problem 4 - Testing Sortedness in Sublinear Time (courtesy of Nathan Harms)
In this question we mean that an array is sorted if it is sorted in increasing order.
Let
An
- if
is sorted, the algorithm output YES with probability 1 - if
is -far from sorted, the algorithm outputs NO with probability at least .
Question 1: the simplest idea for a tester is the random adjacent pair tester, which chooses a random index
Give an example array
Question 2: Another idea is to choose
Give an example of an array that is
Hint: remember the birthday paradox
Question 3: Assume each entry of
- For any set
of good indices, show that the subsequence is sorted. - Show that, if
is -far from sorted, then . - Show that there is an
-tester for sortedness that uses queries.
Hint: consider choosing a random index
Problem 5 - Mixing Time of Random Walks
Compute the mixing time (both upper bounds and lower bounds) of the dumbbell graph: the graph on
Hint: try breaking up the graph into 4 pieces which converge to the stationary distribution in the appropriate time, and then show that any other probability distribution converges quickly to one of these pieces.
Alternative Hint: you can solve this by using elementary probability calculations
Problem 6 - Random Walks (more advanced material)
A cat and a mouse each independently take a random walk on a connected, undirected,
non-bipartite graph
Problem 7 - Pagerank (20 points)
Suppose someone searches a keyword (like “car”) and we would like to identify the webpages that are the most relevant for this keyword and the webpages that are the most reliable sources for this keyword (a page is a reliable source if it points to many of the most relevant pages).
First we identify the pages with this keyword and ignore all other pages. Then we run the following ranking algorithm on the remaining pages.
- Each vertex corresponds to a remaining page, and there is a directed edge
from page
to page if there is a link from page to page . Call this directed graph , where . - For each vertex
, we have two values and , where intendedly represents how relevant is this page and represents how reliable it is as a source (the larger the values the better). - We start from some arbitrary initial values, say
for all , as we have no idea of their relevance at the beginning. - At each step, we update
and (where and are vectors whose entries are and ) as follows: - First we update
for all , as a page is more relevant if it is linked by many reliable sources. - Then we update
for all (using the just updated values ), as a page is a more reliable source if it points to many relevant pages. - To keep the values small, we let
and , and divide each by and each by . - We repeat this step for many times to refine the values.
Let
- Give a matrix formulation for computing
and . - Suppose
is weakly connected (that is, when we ignore the direction of the edges, the underlying undirected graph is connected) and there is a self-loop at each vertex. Prove that there is a unique limiting and a unique limiting for any initial as long as and .
Hint: use the Perron-Frobenius theorem.
Problem 8 - Linear Programming
There are
E.g., if there’s a positive terminal at point
Or, for any
So given the locations of the terminals (and their polarities), the problem is to compute the shortest total length of wires needed to satisfy the stated requirement.
- Consider the following specific instance of the problem. All the terminals are
along the
-axis. There are positive terminals at . And there are negative terminals at and .
What’s the optimal solution to the problem?
(You don’t need to prove your solution is optimal.)
- Formulate this problem as an LP. (Illustrate your LP by writing this for an example with two positive and two negative terminals.)
- Write the dual of the LP in part (2.). (Again, write down this dual for the two terminal example in part (2.).)
- Show how to compute an optimal solution to the dual problem of part (3.), without using a general LP solver.
Hint: see Seidel’s 2D algorithm for LPs
Problem 9 - Linear Programming
Suppose we are given a sequence of
- Describe a linear program whose solution describes the largest axis-aligned square that lies entirely inside
- Describe a linear program whose solution describes the maximum-perimeter axis-aligned rectangle that lies entirely inside
- Describe a linear program whose solution describes the largest circle that lies entirely inside
Problem 10 - Linear Programming
Suppose we are given a sequence of
- Describe a polynomial time algorithm to compute two interior-disjoint axis-aligned squares with maximum total perimeter that lie entirely inside
- Describe a polynomial time algorithm to compute two interior-disjoint axis-aligned rectangles with maximum total perimeter that lie entirely inside
Problem 11 - Linear Programming Duality (basic Helly’s theorem)
Given a finite set of halfspaces