Starting from:
$30

$24

Homework 1 Solution

Suppose we have access to a C function with prototype: bool p_random ();



which returns 1 with probability p and 0 with probability 1−p. Write a C function




int dice_random ();




which is allowed to call the function p_random that returns a number between 1 to 6 at random each with equal likelihood. dice_random should be your only source of randomness in your code.







Consider the variation of the Hiring problem where we have two employees rather than one. As we interview candidates, if we find a candidate that is better than either of our two current employees, we fire the weaker of the current employees and hire the candidate. Determine how many candidates we would hire on average in this situation.









Suppose we toss balls into one of n bins. Assume each bin is equally likely. Calculate with work the expected number of balls you would need to toss until there are two bins with at least two balls.

More products