Algorithm · LinkedIn · Hard
Requirements You are given a binary random generator whose bias is unknown. Use it to construct a generator that returns every integer from 0 through 6 with exactly the same probability. Describe how getRandom06Uniform() can be constructed from getRandom01Biased(). Follow-ups Can the construction be made O(1) in the worst case? How would you adapt the method to generate a uniform value in [0, N)? How could you sample a point uniformly from the area of a disk? Examples The…
Checking your access…