Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CS 6550 Homework 5: Design and Analysis of Algorithms - Problems and Solutions, Exercises of Advanced Algorithms

The instructions and problems for homework 5 of the cs 6550: design and analysis of algorithms course taught by professor jamie morgenstern. The homework covers topics such as counters, data streaming algorithms, and matrix-valued chernoff bounds. Students are expected to solve problems related to maintaining approximate counters, designing streaming algorithms, and proving chernoff bounds for symmetric matrices.

Typology: Exercises

2021/2022

Uploaded on 01/21/2022

elmut
elmut 🇺🇸

4.6

(16)

285 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Design and Analysis of Algorithms, CS 6550 (Professor Jamie Morgenstern ): Homework #5
Homework Out: April 18
Due Date: April 25, midnight
Reminder: this homework is for extra credit! No late days. The HW contains some exercises (fairly simple
problems to check you are on board with the concepts; dont submit your solutions), and problems (for which you
should submit your solutions, and which will be graded). Some problems have sub-parts that are exercises. For this
problem set, its OK to work with others. (Groups of 2, maybe 3 max.) That being said, please think about the
problems yourself before talking to others. Please cite all sources you use, and people you work with. The exp ectation
is that you try and solve these problems yourself, rather than looking online explicitly for answers. Submissions due
at beginning of class on the due date. Please check the Piazza for details on submitting your LaTeXed solutions.
Problems
1. (A Counter, and the Median-of-Means Estimator.). Here is a way of maintaining an approximate
counter. (Call this the basic counter.) Start with X0. When an element arrives, increment Xby 1 with
probability 2X. When queried, return N:= 2X1.
(a) Suppose the actual count is n, show that E[N] = n, and Var(N) = n(n1)
2.
Since its variance is large, average kindependent basic counters N1, N2, . . . , Nk, and output the sample
average ˆ
N:= 1
kPiNi. Call this the k-mean counter.
(b) (Do not submit) Show that
P[ˆ
N /(1 ±)n]1
22k.
Hence using k=1
P22δcounters can make the failure probability at most δ. (Said in other words, your
error is less than n with confidence 1 δ.) Heres a way to use only K=O(1
2log 1
δ) counters to get the
same answer (and the approach is useful in many different contexts beyond this one):
Take a collection of `= 10log 1
δindependent k0-mean counters, where k0=4
2. Output the median Mof
these `counters.
(c) Prove that P[M /(1 ±)n]δ.Hint: what must happen for the the median to be too high? What is the
chance of that?
2. (I Stream, You Stream.). In data streaming model, suppose we denote frequency vector by x=
(x1, x2, ..., xD)ZD
0where xicounts the number of occurences of element i[D] seen so far. We want
a streaming algorithm that stores information about the stream so that when it is eventually queried with
some index q[D], returns a value ˆxqthat is xqwith probability at least 1 δ. We dont want to store x
explicitly, we want to use less space.
Consider the following algorithm:
Keep a global hash function g: [D][d], and also dcounters C1, C2, . . . , Cd(initially zero), each with its own
hash function hi: [D] {−1,+1}. If you see element e[D], first hash it using the global hash function gto
get the bucket number g(e), and then update
Cg(e)Cg(e)+hg(e)(e).
When faced with the query q, output A(q) := hg(q)(q)Cg(q).
Assume that gand the his are all independently picked, and each hash function is itself 2-universal.
(a) Show that E[A(q)] = xq.
(b) Show that the variance of the estimate A(q) = 1
d(F2x2
q)F2/d.
(c) Show that if we set d=1
2δ, our estimate A(q) satisfies
P[A(q)xq±pF2]1δ.
Recall that F2:= Pix2
i=||x||2
2and hence the error term is ||x||2.
1
pf2

Partial preview of the text

Download CS 6550 Homework 5: Design and Analysis of Algorithms - Problems and Solutions and more Exercises Advanced Algorithms in PDF only on Docsity!

Design and Analysis of Algorithms, CS 6550 (Professor Jamie Morgenstern ): Homework #

Homework Out: April 18 Due Date: April 25, midnight Reminder: this homework is for extra credit! No late days. The HW contains some exercises (fairly simple problems to check you are on board with the concepts; dont submit your solutions), and problems (for which you should submit your solutions, and which will be graded). Some problems have sub-parts that are exercises. For this problem set, its OK to work with others. (Groups of 2, maybe 3 max.) That being said, please think about the problems yourself before talking to others. Please cite all sources you use, and people you work with. The expectation is that you try and solve these problems yourself, rather than looking online explicitly for answers. Submissions due at beginning of class on the due date. Please check the Piazza for details on submitting your LaTeXed solutions.

Problems

  1. (A Counter, and the Median-of-Means Estimator.). Here is a way of maintaining an approximate counter. (Call this the basic counter.) Start with X ← 0. When an element arrives, increment X by 1 with probability 2−X^. When queried, return N := 2X^ − 1.

(a) Suppose the actual count is n, show that E[N ] = n, and Var(N ) = n(n 2 − 1). Since its variance is large, average k independent basic counters N 1 , N 2 ,... , Nk, and output the sample average Nˆ := (^1) k

i Ni^. Call this the^ k-mean counter. (b) (Do not submit) Show that P[ N /ˆ∈ (1 ± )n] ≤ 1 2 ^2 k

Hence using k = (^) P 21  (^2) δ counters can make the failure probability at most δ. (Said in other words, your error is less than n with confidence 1 − δ.) Heres a way to use only K = O( (^) ^12 log (^1) δ ) counters to get the same answer (and the approach is useful in many different contexts beyond this one): Take a collection of = 10log (^1) δ independent k 0 -mean counters, where k 0 = (^) ^42. Output the median M of these counters. (c) Prove that P[M /∈ (1 ± )n] ≤ δ. Hint: what must happen for the the median to be too high? What is the chance of that?

  1. (I Stream, You Stream.). In data streaming model, suppose we denote frequency vector by x = (x 1 , x 2 , ..., xD ) ∈ ZD ≥ 0 where xi counts the number of occurences of element i ∈ [D] seen so far. We want a streaming algorithm that stores information about the stream so that when it is eventually queried with some index q ∈ [D], returns a value ˆxq that is ≈ xq with probability at least 1 − δ. We dont want to store x explicitly, we want to use less space. Consider the following algorithm: Keep a global hash function g : [D] → [d], and also d counters C 1 , C 2 ,... , Cd (initially zero), each with its own hash function hi : [D] → {− 1 , +1}. If you see element e ∈ [D], first hash it using the global hash function g to get the bucket number g(e), and then update

Cg(e) ← Cg(e) + hg(e)(e). When faced with the query q, output A(q) := hg(q)(q)Cg(q). Assume that g and the his are all independently picked, and each hash function is itself 2-universal.

(a) Show that E[A(q)] = xq. (b) Show that the variance of the estimate A(q) = (^1) d (F 2 − x^2 q ) ≤ F 2 /d. (c) Show that if we set d = (^) ^12 δ , our estimate A(q) satisfies

P[A(q) ∈ xq ± 

F 2 ] ≥ 1 − δ.

Recall that F 2 :=

i x^2 i =^ ||x||^22 and hence the error term is^ ||x||^2.

Design and Analysis of Algorithms, CS 6550 (Professor Jamie Morgenstern ): Homework #

(d) Finally, consider an extension of this idea: maintain t independent copies of the above data structure. On a query for q, if the answers from the individual copies of the data structure are A 1 (q), A 2 (q), ..., At(q), return the median M (q) of these t answers. Show that with t = c 1 log 1+ δ , and d = c ^22 , where c 1 , c 2 are constants you can choose, you get M (q) ∈ xq ± ||x|| 2 with probability 1 − δ.

  1. (Chernoff meets Matrices). In Lecture 18 we mentioned a very general theorem about matrix-valued Chernoff bounds for symmetric matrices. In this problem well take the first steps towards it. Assume eigenvalues are numbered so that λ 1 ≥... λn. Well prove:

Theorem 1. Let X 1 , X 2 ,... , Xn be independent symmetric d × t matrices, and Sn =

i X)i. Then, for any t ≥ 0 and ∈ R, P[λ 1 (Sn) ≥] ≤ d · e−t`^ ·

∏^ n

i=

λ 1 (E[etXi^ ]).

P[λd(Sn) ≤ −] ≤ d · e−t^ ·

∏^ n

i=

λ 1 (E[e−tXi^ ]).

Recall that tr(A) =

∑n i=1 aii. You may use the following without proof: i. tr(A) =

i λi(A) ii. λi(eA) = eλi(A) iii. The Golden-Thompson inequality: tr(eA+B^ ) ≤ tr(eA^ · eB^ ). iv. For PSD matrices A and B, tr(AB) ≤ tr(A) · tr(B). v. Expectations and trace commute: E[tr(A)] = tr(E[A]). (a) Show that for any t ≥ 0,

P[λ 1 (Sn) ≥ ] ≤ P[tr(etSn^ ) ≥ et] ≤ e−t`^ · E[tr(stSn^ ].

(b) Show that EX 1 ,...,Xn [tr(etSn^ )] ≤ EX 1 ,...,Xn− 1 [tr(etSn−^1 )] · λ 1 (E[etXn^ ]). Hint: why can you use (iv) above even if Xn isn’t PSD? (c) Use the previous two parts to prove the first statement of the theorem. (d) Use the same arguments on (−Sn) =

i(−Xi) to prove the other part.