Randomized Algorithms, Exercises Solution- Discrete Mathematics 2, Exercises of Discrete Structures and Graph Theory

Discrete Structures, Randomized Algorithm, Exercises, Exam Paper

Typology: Exercises

2010/2011

Uploaded on 10/12/2011

lovefool
lovefool 🇬🇧

4.5

(21)

292 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
6.856 Randomized Algorithms
Karger
Handout #5, February 16, 2011 Homework 2 Solutions
Problem 1.
(a)
As in the class, we can construct an adversarial input as follows. When replying to al-
gorithm’s queries on leaves, we always reply such that for any tree, if not all leaves were
queried, then the value of the tree is not yet determined. In this case, for each internal node,
the algorithm is forced to evaluate each of its children.
For a node x, call val(x) the value of x.
We do this as follows. Suppose the algorithm queries leaf x, and let n1, n2, . . . , nh1, nh=
xbe the path from root (n1) to xin the tree. Let nibe the lowest node such that there
exists a non-examined leaf in ni’s subtree (xbeing counted as “examined”). Then, if nihas
0 children with established value (ni+1 begin considered with non-established value), then
we choose val(x) = 0 (in which case, val(ni+1 ) = val(ni+2 ) = · · · =valnh= 0). If nihas
1 child with established value (ni+1 begin considered with non-established value), then we
choose val(x) = 1 (in which case, val(ni+1 ) = val(ni+2 ) = · · · =val(nh) = 1). Note that
the value of the first child of niis 0, and therefore the value of niremains un-established.
Also, note that by the definition of ni,nicannot have 2 children with established value (ni+1
being considered with non-established value).
Thus, for each node, the algorithm has to establish the value of all of its 3 children
which means that the algorithm has to query all 3hleaves.
(b)
Consider a node xin the tree. Let its value be val(x). This means that there are two
children child1(x) and child2(x) such that val(x) = val(child1(x)) = val(child2(x)). If, for
each x, we know that these children child1(x) and child2(x), then we can only compute
the values of these children to compute the value of x. Thus, a non-deterministic algo-
rithm can just guess child1(x) and child2(x) and reccurse on those 2. If val(child1(x)) =
val(child2(x)) then we know for sure that val(x) = val(child1(x)) = val(child2(x)). If
val(child1(x)) 6=val(child2(x)) then we fail on that branch. At least one of the branches of
the non-deterministic algorithm will succeed and give the right answer.
1
pf3
pf4
pf5

Partial preview of the text

Download Randomized Algorithms, Exercises Solution- Discrete Mathematics 2 and more Exercises Discrete Structures and Graph Theory in PDF only on Docsity!

6.856 — Randomized Algorithms

Karger

Handout #5, February 16, 2011 — Homework 2 Solutions

Problem 1.

(a)

As in the class, we can construct an adversarial input as follows. When replying to al- gorithm’s queries on leaves, we always reply such that for any tree, if not all leaves were queried, then the value of the tree is not yet determined. In this case, for each internal node, the algorithm is forced to evaluate each of its children. For a node x, call val(x) the value of x. We do this as follows. Suppose the algorithm queries leaf x, and let n 1 , n 2 ,... , nh− 1 , nh = x be the path from root (n 1 ) to x in the tree. Let ni be the lowest node such that there exists a non-examined leaf in ni’s subtree (x being counted as “examined”). Then, if ni has 0 children with established value (ni+1 begin considered with non-established value), then we choose val(x) = 0 (in which case, val(ni+1) = val(ni+2) = · · · = valnh = 0). If ni has 1 child with established value (ni+1 begin considered with non-established value), then we choose val(x) = 1 (in which case, val(ni+1) = val(ni+2) = · · · = val(nh) = 1). Note that the value of the first child of ni is 0, and therefore the value of ni remains un-established. Also, note that by the definition of ni, ni cannot have 2 children with established value (ni+ being considered with non-established value). Thus, for each node, the algorithm has to establish the value of all of its 3 children – which means that the algorithm has to query all 3h^ leaves.

(b)

Consider a node x in the tree. Let its value be val(x). This means that there are two children child 1 (x) and child 2 (x) such that val(x) = val(child 1 (x)) = val(child 2 (x)). If, for each x, we know that these children child 1 (x) and child 2 (x), then we can only compute the values of these children to compute the value of x. Thus, a non-deterministic algo- rithm can just guess child 1 (x) and child 2 (x) and reccurse on those 2. If val(child 1 (x)) = val(child 2 (x)) then we know for sure that val(x) = val(child 1 (x)) = val(child 2 (x)). If val(child 1 (x)) 6 = val(child 2 (x)) then we fail on that branch. At least one of the branches of the non-deterministic algorithm will succeed and give the right answer.

The number of leaves queried (in each branch) is given by the reccurence formula: T (h) = 2 T (h − 1) (where T (0) = 1) and it solves to 2h, which is 2log^3 n^ = nlog^3 .

(c)

Consider a node x at level t. x has at least two children that agree on their values (e.g., child 1 (x) and child 2 (x)). If the third child has a different value, then: there is a probability of 1/3 that the randomized algorithm will compute the value of only child 1 (x) and child 2 (x); and probability of 2/3 that the algorithm with compute the value of all three children. If the third child has the same value with the other 2 children, then the algorithm will compute the value of only 2 of its children. Thus, if we call T (t) the number of leaves queried for a node at height t, then: either E[T (t)] = 1/ 3 · 2 E[T (t − 1)] + 2/ 3 · 3 E[T (t − 1)] = 8/ 3 · T (t − 1) (in the first case) or E[T (t)] = 2E[T (t − 1)] (in the second case). Thus, E[T (t)] ≤ 83 E[T (t − 1)]. With T (0) = 1, this solves to E[T (t)] = (^83 )t. Concluding, we have that E[T (h)] ≤ (^83 )log^3 n^ = nlog^3 8 /^3 ≤ n.^8928.

Current problem finished. Skipped a page to next problem.

Problem 3.

(a)

Consider a subsequence of coin flips of length log 2 n + c. Such a subsequence has probability of exactly (^12 )log^2 n+c^ = n−^12 −c^ that all the coins flips in the considered subsequence are heads. There are in total n − log 2 n − c + 1 such subsequences in the sequence of length n, and, therefore, by union bound, there is a probability of ≤ (n − log 2 n − c + 1) · n−^12 −c^ ≤ n · n−^12 −c^ = 2−c^ that there exists a subseqence of length log 2 n + c of heads.

(b)

Let l = log 2 n − a log 2 log 2 n − c, where a, c are constants. Divide the entire sequence into n/l subsequences of length l. One such subsequence has a probability 2−l^ of having all coins heads. Therefore, the probability P that none of the n/l subsequences is all heads is

P ≤ (1 − 2 −l)n/l. Let’s compute this probability: P ≤ (1 − 2 −l)n/l^ = (1 − 2

c (^) loga 2 n n )

n/l (^) ≤

(1 − 2

c (^) loga 2 n n )

n/ log 2 n (^) ≤ exp[−^2 c^ loga 2 n log 2 n ]^ ≤^ exp[−^2

c (^) log 2 n] =^ n − 2 c^ log 2 e (^) for a = 2. Since we can

choose the constant c as big as we want, we achieve that whp (1 − n−const), there will exist a subsequence of heads of length l.