Probability Algorithm Writes 2 0 Rand 1 2 Rand 1 2 Print Explain Well Q37219004

What is the probability that the algorithm below writes out2?

i = 0

while rand(1,2) != rand(1,2)

i++

print i

Explain well!   


Answer


Here we are generating the number between 1 and 2 so here

1/2=.5 so we have 50% probability to write the number 2

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.