**Question:** The probability of a car passing a certain intersection in a 20 minute windows is 0.9. What is the probability of a car passing the intersection in a 5 minute window? (Assuming a constant probability throughout)

**Answer:** This is one of the basic probability question asked in a software interview. Let’s start by creating an equation. Let **x** be the probability of a car passing the intersection in a 5 minute window.

Probability of a car passing in a 20 minute window = 1 – (probability of no car passing in a 20 minute window)

Probability of a car passing in a 20 minute window = 1 – (1 – probability of a car passing in a 5 minute window)^4

0.9 = 1 – (1 – x)^4

(1 – x)^4 = 0.1

1 – x = 10^(-0.25)

x = 1 – 10^(-0.25) = **0.4377**

That was simple eh. Ready for a challenge? Have a look at some of the other probability questions.

If you like this post, please Digg it or thumbs up on stumble upon. 🙂

**If you're looking for some serious preparation for your interviews, I'd recommend this book written by a lead Google interviewer. It has 189 programming questions and solutions:**

If the probability of a car passing the intersection in 20 minutes is x%, the probability that it occurs in the first five minutes is (X/4)%. For the second five minutes, it’s also (X/4)%, etc. So the total for the 20 minutes is (X/4) + (X/4) + (X/4) + (X/4) = x%.

Change the probability to 1. Roadblock?

@Eric Fredine

The integral of exp(ct) is 1/c*exp(ct). Additionally if you say the probability density is exp(ct) why can you say 0.1 = exp(20c). The density function does not give you the actual probability. You would have to integrate over t first.

Am I missing something?

TKI, sorry that’s not right.

The probability of the event happening in 5 min interval must be obviously < 0!!!

Abhishek, the problem assumes a constant distribution and hence the probabilities are equal.

Let p = probability that the events happens in 5 min interval.

Let q = probability of event happening in 20 min interval.

Then probability of the event not happening in the 20 min interval is = (1-q)

= (1-p)*(1-p)*(1-p)*(1-p)

= (1-p)^4

so, p= 1 – (1-q)^(1/4)

This solution seems synthetic to me. This is dividing time up into 5 minute intervals and treating the problem as a series of bernoulli trials.

Why is the solution not based on poisson distribution?

Fun stuff. Here’s another solution:

Since the probability throughput is constant, the probability density function for not seeing a car is given by:

ProbNoCar(t) = e^ct where c is a constant that determines the rate of decay. The actual probability is given by the integral of e^ct which is e^ct (nice property of e).

So, now we just need to determine c.

ProbNoCar(20) = 0.1 = e^c*20

c*20 = ln(0.1) = -2.3026

c = -0.1151

and plug in 5:

ProbNoCar(5) = e^-0.1151*5 = 0.5623

and subtract it from 1:

ProbCar(5) = 1 – ProbNoCar(5) = 0.4377

Hi I read your solution for the above problem. Initially I found the solution convincing but I got stuck in the same logic you used

you used that probability (of a car not passing in 20 minutes window) is 4 times of the probability (of a car not passing in 5 minutes window )

Using the same logic

probability (of a car passing in 5 minutes window ) = 1 – probability (of a car not passing in 5 minutes window )

probability (of a car passing in 5 minutes window ) = 1 – [ {probability (of a car not passing in 20 minutes window )/4}]

x = 1 – (0.1/4) gives x = 0.975

kindly clear my problem

I beg to differ, and fail to agree with your solution.

The hinge of your solution is that:-

Probability that no car passes in a 20 minute window= ( P(no car passing in a 5 min. window))^4

This reasoning, I think, is wrong. Its the following that makes sense:

P(no car passing in a 20 min window)=

P(no car passing in the first 5 mins)*P(no car passing in the second 5 mins)*P(no car passing in the third 5 mins)*P(no car passing in the last 5 mins)

And the probability of a car going in each of the 5-min frame isn’t equal.. because, each probability depends upon the previous one.

I have a solution(a rather lengthy one), crafted from my approach. Tell me if you agree so far, so that I may post it.

That is a valid point. I guess I should have phrased the question as “at least one car passing by”. 🙂

Isn’t this only valid if ‘a car passing by’ is meant to mean ‘one or more cars passing by’ instead of ‘exactly one car passing by’?

Blog looks really good mate, keep it up! The information is delivered solidly! 🙂