hw_sol_08 - CS 473 Fundamental Algorithms Spring 2011 HW 8...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 473: Fundamental Algorithms, Spring 2011 HW 8 Question 1 is due by Sunday, 23:59:59, April 3 Questions 2-4 are due by Monday, 23:59:59, April 4 This homework contains four problems. Read the instructions for submitting homework on the course webpage . Collaboration Policy: For this homework, Problems 2–4 can be worked in groups of up to three students. Problem 1 should be answered in Compass as part of the assessment HW8-Online and should be done individually. 1. HW8-Online. (10 pts.) 2. Coins and stuff. (30 pts.) (A) (5 pts.) You are given a fair coin that returns heads with probability 1 / 2. Prove that there is no algorithm that can perform a constant number of coin flip operations, and output 1 with probability 1 / 3 and 0 with probability 2 / 3. Solution : Let k be any constant. For the sake of contradiction, suppose there is an algorithm Alg that uses at most k tosses of the fair coin and outputs 1 with probability 1 / 3 and 0 with probability 2 / 3. To simplify our argument, WLOG, we can assume that the algorithm uses exactly k coin tosses. That is, the algorithm always tosses the coin k times and is allowed to ignore some coin toss results. Then the algorithm must output 0 or 1 for each sequence of length k comprises heads or tails. Since each sequence occurs with probability 1 / 2 k , the algorithm outputs 1 with probability h/ 2 k where h is a non-negative integer. We obtain a contradiction since h/ 2 k 6 = 1 / 3. (B) (5 pts.) Describe an algorithm that using a fair coin outputs 1 with probability 1 / 3 and 0 with probability 2 / 3. The expected number of coin flips of your algorithm uses should be O (1). Solution : Let H and T denote head and tail, respectively. The outcome set Ω when we toss the coin twice is { HH,HT,TH,TT } . We repeats tossing the coin twice until we have HH , HT or TH . If we have HH then we output 1. If we have HT or TH , we output 0. 1 (C) (10 pts.) Describe a simple algorithm that given n picks uniformly in random a number between 1 and n (where all the numbers have the same probability to be picked). The algorithm can use only fair coin flips. How many coin flips does your algorithm uses in expectation? How many coin flips does your algorithm uses in the worst case? Solution : Let h = d log 2 n e . By tossing the coin h times, we can obtain an integer x uniformly from [1 , 2 d log 2 n e ]. If we have x ≤ n , we output n and stop. Otherwise, we repeat this process....
View Full Document

{[ snackBarMessage ]}

Page1 / 5

hw_sol_08 - CS 473 Fundamental Algorithms Spring 2011 HW 8...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online