CS513: Homework 3 Solutions
Instructor: S. Muthukrishnan, TA: D. Desai
February 28, 2011
1. A simple greedy algorithm that scans the array A from left to right is optimal. Starting from l0 = 0,
l
nd the rightmost point l1 such that j1 Aj W . Keep repeatin
CS513: Homework 1 Solutions
Instructor: S. Muthukrishnan, TA: D. Desai
February 28, 2011
1. The correct order is
2 log log n
n1000/ log n , 2
, log n, 0.001n3 , (n + 1)!, 22
n
+log n
n
, n 22 .
Here, one can use the trick x = 2log x . The rst function is
CS513: Homework 6 Solutions
Instructor: S. Muthukrishnan, TA: D. Desai
April 29, 2011
1. The algorithm chooses a random vector r cfw_0, 1n , where each entry in r is chosen uniformly at
random to be 0 or 1. We output YES if ABr = Cr and NO otherwise. The
CS513: Homework 2 Solutions
Instructor: S. Muthukrishnan, TA: D. Desai
March 10, 2011
1. Let (n) denote the number of primes before n. Then the number of primes in the interval [x, y ] is
(y ) (x). So the probability that a uniformly random number chosen
CS513: Homework 4 Solutions
Instructor: S. Muthukrishnan, TA: D. Desai
March 21, 2011
1. The running times of Bellman-Ford (O(|V | |E |) and Floyd Warshall (O(|V |3 ) will not change due
to integer weights. For Dijkstras algorithm, the running time is det
CS513: Homework 5 Solutions
Instructor: S. Muthukrishnan, TA: D. Desai
March 17, 2011
1. The max-ow min-cut theorem states that in any graph, the size of a maximum (s, t)-ow equals the
size of the smallest (s, t)-cut. If we pick an arbitrary vertex s and
CS513: Midterm Solutions
Instructor: S. Muthukrishnan, TA: D. Desai
April 28, 2011
1. (a) A naive implementation requires around 2n comparisons. The following procedure is better. We
will do comparison only between adjacent pairs (so n/2 comparisons). The