Amazon Interview Question
Software Engineer / Developersaaply
Multiplication Rule 1: When two events, A and B, are independent, the probability of both occurring is:
P(A and B) = P(A) ยท P(B)
This solution is correct, it is the combined probability of all possible events minus the probability that all four people will NOT open the door (1/2)^4. Another way to look at this problem would be to take the sum of the probabilities of all possible ways that the door will be opened:
P[person a opens the door] = 0.5
+ P[2 people open door] = P[person a] * P[person b] = 0.25
+ P[3 people open door] = P[person a] * P[person b] * P[person c] = 0.125
+ P[all 4 open door] = P[person a] * P[person b] * P[person c] * P[person d] = 0.0625
= 0.5 + 0.25 + 0.125 + 0.0625 = 0.9375 that the door will be opened, or 15/16.
the probability of somebody opening the door is 1/2
it means we are not aware of the probabilities of other three people. so we can't assume anything.
Now the door can be opened only when this 'somebody' opens the door.
The probability of selecting this 'somebody' out of four people is 1/4
And hence the probability of the door being opened = P ( selecting somebody) * P( somebody opening the door)
= 1/4 * 1/2 = 1/8
two people open the door at same time = 1/2 *1/2 = 1/4
three people open the door at same time = 1/2 * 1 /2 * 1/2 = 1 /8
four people open the door at same time = 1/2 * 1/2 * 1/2 * 1/2 = 1/ 16
more than one people open the door at same time = 1/4 + 1/8 + 1/ 16 = 7/16
only one person open the door = 1 - 7 / 16 = 9 / 16
????
I agree with this answer, even I got the same o/p with another approach
Four of them opening the door : 1/2
One of them opening the door : 1/2*1/2*1/2*1/2=1/16
Opening the door: one of them or four of them = 1/2+1/16=9/16
That's wrong.
only one person open the door = 1 - 7 / 16 - Prob(nobody opens the door) = 1 - 7 / 16 - 1 / 16 = 8 / 16 = 1 / 2
The same answer can be obtain in the following way:
only one person open the door = Pob(first_person_is_selected) * Prob(first_person_opens_the_door) + .. + Pob(fourth_person_is_selected) * Prob(fourth_person_opens_the_door) = 1/4 * 1/2 + .. +1/4 *1/2 = 1/2
simple:
a|b only excludes the possibility ^a&^b so p(a|b) + p(^a^b)=1 =>p(a|b)=1-p(^a^b)
also p(ab)=p(a)*p(b) => p(a|b) = 1-p(^a&^b) = 1-p(^a)*p(^b)
so probability p(a|b|c|d) = 1-p(^a^b^c^d)=1-(.5*.5*.5*.5) = 93.75/100
you can derive probability equations using logical deduction + simple mathematics.
Lets try to understand it in a different way. By definition, the probability that a ceratin event will happen is: number of favourable outcomes divided by total number of outcomes.
so in this case, number of favourable outcomes (i.e. the door will be opened) = number of ways so that atleast of one the person opens the the door.
Total number of outcomes = 2 * 2 * 2 * 2 = 16, because each person can indepenedently have two different options: either to open the door, or not to. So, total outcomes is 16.
out of these 16 outcomes, only one outcome is unfavourable i.e. all four DO NOT open the door. rest in all other 15 cases, atleast one of the persons will definitely open the door.
Therefore, P(i can enter) = 15/16 = 93.75 %
I opened this thread because lot of people confused in this puzzle ..acc to me i think its clear that question says somebody not particular person ..isn't it so if any1 will open the door then one can get inside ..isn't it...& thats the 1/2 ..i don't why confusion ??? let me know if i missed sunmthing
I agree with this. As there are no condition like that... any body open the Door and every probability is 1/2 so total probability of opening the door is adding 1/4*1/2 4 times which comes as 1/2. there is no condition between any person.
@WgpShashank--> as you calculated the probability of not opening the Door is 1/2*1/2*1/2*1/2 and subtracting it from 1. Similarly I can say probability of opening the door is 1/2*1/2*1/2*1/2 which comes as 1/16 which is not same as your answer.
@Sanjay:
How can you say that probability of opening the door is 1/16. You calculated when every body inside the room open the door at the same time.
Probability of getting in is that at least one person opens the door which is same as (1-p(no body opens the door)). So in my opinion AK is correct.
@Tulley Please read the question carefully. the statement is somebody open the door is 1/2 mean the probability of opening the door is 1/2. No where is given the probability of opening the door by each person is 1/2.
for one person, the possible action is taking no action, opening 1/2 and opening the door, every action has 1/3 possibility. The only way you can not enter is 3 person no action, the forth one takes no action or opens 1/2, which the possibility is (1/3) * (1/3) * (1/3) * (2/3) = 2/81.
So my answer is 1- 2/81 = 79/81.
It is
- AK May 20, 2011