Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3. We are given a length-n binary list L. In other words, L 60, 1} for all j = 1,2, , n. Our problem is
3. We are given a length-n binary list L. In other words, L 60, 1} for all j = 1,2, , n. Our problem is to count the number of 0's in L. We could of course solve this problem in (n) time by simply scanning L, but we want to solve it faster and so we turn to randomization. The randomized algorithm we use is the following function CountZerOES(L) n length(L) count 0 for j 1 to 100 do Comment: pick a random index i between 1 and n i random(1, n) if L 0 then count count + 1 return n count/100 (a) What is the running time of this algorithm? Please show all your work (b) Suppose that n 106 and exactly a quarter of the elements in L are 0, what is the probability that the CountZeroes function returns 01? (c) A random variable X has binomial distribution with parameters m (a positive integer) and p (a real number between 0 and 1) if The way to think about X being binomially distributed is that we perform m indepen- dent random trials and each trial can either succeed or fail. The "success" probability of a trial is p and so the failure probability of a trial is 1 - variable X represents the number of successful trials, out of m total random trials To understand the formula in (1) note that the probability of k successful trials is p* the probability of (m-k) unsuccessful trials is (1-p)m-k, and there are (79 ways of distributing the k successful trials among the m random trials As in (b) suppose that n 106 and exactly a quarter of the elements in L are 0 Using the above expression for a binomial distribution, write down the expression for the probability that CouNTZErOES returns the correct answer, namely 106/4. p. Then the random
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started