Solved–Homework 1 –Solution

$30.00 $19.00

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…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

5/5 – (1 vote)
  1. 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.

  1. 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.

  1. 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.