Microsoft Interview Question
I actually should be:
x = 1/3*0 + 1/3(1+x) + 1/3(2+x)
3x=1+x+2+x
x=3
The expected number of days is 3.
I have a different opinion on this.
Trying to summarize theq question again.
E(x) = Sumation(i) pi * xi = p0x0 + p1x1 + p2x2;
p0 = p1 = p2 = 1/3 ( Equally likely event to choose gate)
x0 = 0 days in Hell = 0
x1 = 1 days in Hell = 1
x2 = 2 days in Hell = 2
Objective is to find how many days in hell?
Expected value for a person in days to reach heaven is
E(x) = (1/3)*(0) + (1/3)*(1) + (1/3)*(2) = 1
Person would take one expected day to reach Heaven.
Please provide more details on earlier posted solution if you think 1 is not a solution.
Thanks
Ankush
Ankush,
1 would be the solution if after staying one time in hell a person would always go to heaven. However, after hell a person is tried again so an unlucky (or lucky) one could stay in hell for a very long time.
If you still don't believe the result run a simple simulation:
length = 0
repeat 10000000 times
repeat
choice = random from 0, 1, 2
length = length + choice
exit when choice = 0
end repeat
end repeat
average = length / 10000000
The Solution seems correct to me.
As the probability of choosing a door is same.
p0=p1=p2=1/3
Even if they are shuffled.
Now if the person chooses the door to heaven the value of xi becomes 0.
Else, if he chooses 1 day @ Hell and then heaven the value of xi becomes 1.
Finally if he chooses 2 days @ Hell and then Heaven the value of xi becomes 2.
So,
Expected value for a person in days to reach heaven is
E(x) = (1/3)*(0) + (1/3)*(1) + (1/3)*(2) = 1
This is correct :)
Wrong. if he chooses 1 day @ hell, xi = 1 + xi. If chooses 2 days @ hell, xi = 2 + xi. Got it or not.
Let x be the random variable of days to reach heaven. we need expected value of that rv
- tridgell August 23, 2009x = 1/3*1 + 1/3(1+x) + 1/3(2+x)
3x = 1 + 1+x + 2+x
3x = 4 + 2x
x = 4