Microsoft Interview Question






Comment hidden because of low score. Click to expand.
0
of 0 vote

Let x be the random variable of days to reach heaven. we need expected value of that rv

x = 1/3*1 + 1/3(1+x) + 1/3(2+x)

3x = 1 + 1+x + 2+x

3x = 4 + 2x

x = 4

- tridgell August 23, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

why not x = 1/3*x + 1/3(1+x) + 1/3(2+x) ? since the first term means after x days when the person goes back, the first gate is chosen then the person can go to the heaven immediately. but there is no solution then if changed the first term.

- Anonymous August 23, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

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.

- espresso August 24, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yep, you are correct!!

- shaminda September 28, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Is there any other probable solution??

- sa August 25, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

i agree with espresso answer should be 3

- wolverine August 28, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

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

- ankushbindlish August 29, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

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

- espresso August 29, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

This would have been altogether different question "if after staying one time in hell a person ".

Please provide solution to support your comments.

- Anonymous August 30, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The three doors are shuffled every morning. So what if the person always ends up opening the 2day hell door.

- Anonymous October 04, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

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 :)

- SJ October 06, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Wrong. if he chooses 1 day @ hell, xi = 1 + xi. If chooses 2 days @ hell, xi = 2 + xi. Got it or not.

- anon November 09, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Please elaborate how does it come to be "x1 = 1 + x" if he chooses '1 day @hell' door. Are the cases like '1 day @hell > 2 day @hell > 1 day @hell > 1 day @hell > ... > heaven' included? If yes, how?

- Shishir September 07, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

He should follow islam.. He'll always go to heaven... with probability 1...
OBL {Allah hu akbar allah}

- saurabh.comps November 08, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think expresso is right.

- Gajanan March 13, 2010 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More