Amazon Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: Written Test
You forgot a factor of 2 in the 8!/3*5! term it should instead be 8!/(3!*5!). Your numerical answer is correct though.
Can someone tell me why is there a '1' in the numerator (3!/2! + 1)/2^3.
I thought is should just (3!/2!)/2^3
I would say the second challenge.
The first challenge requires you to make it 66% of the time while the second challenge only requires you to make it 63%. The drop of 3% might be significant.
Also, the condition for independence between shoot is questionable. As you try 8 times, you have more practices and might be able to make it into the basket in the subsequent throws. Therefore, the option of trying 8 times might mean better chance of winning the game.
That's what I think from my statistics perspective.
Amount of ways to win challenge 1:
C(3, 2) + C(3, 3)
, amount of ways to lose challenge 1:
C(3, 0) + C(3, 1)
. But
C(n, k) === C(n, n-k)
, so
C(3, 2) === C(3, 1), C(3, 0) === C(3, 3)
.
Amount of ways to win challenge 2:
C(8, 5) + C(8, 6) + C(8, 7) + C(8, 8)
and amount of ways to lose challenge 2:
C(8, 0) + C(8, 1) + C(8, 2) + C(8, 3) + C(8, 4)
, but
C(8, 8) === C(8, 0), C(8, 1) === C(8, 7), C(8, 2) === C(8, 6), C(8, 3) === C(8, 5)
so, amount of ways to lose in the second case are greater.
It depends on the probability of winning.
This is a classic example of bernoulli trial.
P(2 out 3) = (3 Choose 2) p^2 * (1-p)
P(5 out 8) = (5 Choose 8) p^5 * (1-p)^3
solving this:
P^3 * (1-P)^2 >= 15/56
Therefore, the second option is a better choice for the values of p that satisfy above condition.
First, compute probability of getting success (2 out of attempts):
1. Compute sample space i.e., All possible outcomes of 3 attempts: 8 BBB, BBN, BNB,...etc. Where B->Basket and N->No Basket.
2. Compute How many of the 8 outcomes above have atleast 2 Baskets in them.
Ans: 4 or 3C2+1 (1 for combination with all 3 baskets).
3. Now final step for challenge 1: Probablity of achieving success (2 out of 3 attemts)=4/8 or 0.5.
Now Challenge 2:
1. 8 attempts, possible outcome combinations are: 256.
2. Number of possible combinations of 5 baskets in these 256 outcomes: 8C5+8C6+8C7+8C8=93.
3.Now compute probability of success for challenge 2 i.e., 5 out of 8 attempts: 93/256= ~0.30
Hence, it is better to take Challenge 1 as Prob of success for it (0.5) is greater than the second challenge
It depends.
Let the probability to make a shot be p.
The probability to win challenge one is:
(3 choose 2) p^2 (1-p) + (3 choose 3) p^3
since you can win by either hitting two shots or all three shots.
For challenge 2 it is
(8 choose 5) p^5 (1-p)^3 + (8 choose 6) p^6 (1-p)^2 +(8 choose 7) p^7 (1-p) + p^8
since you can either make 8,7,6 or 5 of the shots to win.
If the probability p is below ~65% challenge one is the one you should choose, if it's above challenge two. So three point shots --> 1 , layups or free throws (if you are a good free throw shooter) --> 2
okay ... probability of winning first game 2/3
probability of winning second game is 5/8
i was taught in 8th grade that to compare two fractions you make their denominators same....
(so take LCM) and the probability of winning first game becomes : 16/24
and the second game becomes : 15/24
since 16/24> 15/24 so the person should play the first game.
okay ... probability of winning first game 2/3
probability of winning second game is 5/8
i was taught in 8th grade that to compare two fractions you make their denominators same....
(so take LCM) and the probability of winning first game becomes : 16/24
and the second game becomes : 15/24
since 16/24> 15/24 so the person should play the first game.
okay ... probability of winning first game 2/3
probability of winning second game is 5/8
i was taught in 8th grade that to compare two fractions you make their denominators same....
(so take LCM) and the probability of winning first game becomes : 16/24
and the second game becomes : 15/24
since 16/24> 15/24 so the person should play the first game.
Let,
A = the event that you make 2 out of 3 baskets
B = the event that you make 5 out of 8 baskets
p = the probability of a single success (i.e. you make a basket)
q = the probability of a single failure (i.e. you miss the basket)
Then you should always choose event A (the first option) over event B (the second option).
Note that:
3 choose 2 = 3!/[(3-2)!*2!] = 3
8 choose 5 - 8!/[(8-5)!*5!] = 56
Pr(A) = 3*(p^2)*(q^1)
Pr(B) = 56*(p^5)*(q^3)
And hence we should the first option over the second option when: Pr(A)/Pr(B) > 1
or equivalently when: Pr(B)/Pr(A) < 1
Note that we are indifferent between option 1 and option 2 when Pr(A)/Pr(B) = 1
Finally, note that:
Pr(B)/Pr(A) = [56*p^5*q^3] / [3*p^2*q]
= 56/3*p^3^q^2
<= 56/3*(1/2)^3*(1/2)^2
= 56/3*(1/2)^5
= 56/3*(1/32)
= 56/96
< 1
And therefore, since Pr(B)/Pr(A) < 1 for any value of p between 0 and 1, we conclude that the first option is always "better" (i.e. more likely) than the second option.
Let,
A = the event that you make 2 out of 3 baskets
B = the event that you make 5 out of 8 baskets
p = the probability of a single success (i.e. you make a basket)
q = the probability of a single failure (i.e. you miss the basket)
Then you should always choose event A (the first option) over event B (the second option).
Note that:
3 choose 2 = 3!/[(3-2)!*2!] = 3
8 choose 5 - 8!/[(8-5)!*5!] = 56
Pr(A) = 3*(p^2)*(q^1)
Pr(B) = 56*(p^5)*(q^3)
And hence we should the first option over the second option when: Pr(A)/Pr(B) > 1
or equivalently when: Pr(B)/Pr(A) < 1
Note that we are indifferent between option 1 and option 2 when Pr(A)/Pr(B) = 1
Finally, note that:
Pr(B)/Pr(A) = [56*p^5*q^3] / [3*p^2*q]
= 56/3*p^3^q^2
<= 56/3*(1/2)^3*(1/2)^2
= 56/3*(1/2)^5
= 56/3*(1/32)
= 56/96
< 1
And therefore, since Pr(B)/Pr(A) < 1 for any value of p between 0 and 1, we conclude that the first option is always "better" (i.e. more likely) than the second option.
I can win the first challenge with 50% probability:
And the second one with 36% probability:
- Daniel November 15, 2014