Microsoft Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




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

this is super easy. split the ball into three groups with 3 balls each. pick two groups out to measure if they are equal weight. this way, you could find out which group contains the heavy ball. Then from this particular group, you could pick two to do one more measurement, this way, you find out the heavy ball

- June October 27, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

correct

- manju November 22, 2013 | Flag
Comment hidden because of low score. Click to expand.
4
of 8 vote

Stop posting questions from the web. Microsoft stopped asking these a long time ago. Get with the program.

- Anonymous October 27, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Actually I was asked this exact question during the phone interview.

- alex December 08, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Create three groups of 3 balls each.
Compare two of these groups (1st comparison)
If equal
   Compare the two balls in second group (2nd comparison)
   If equal
       Return the uncompared ball
   Else
       Return the ball that is heavier
Else 
   Compare the balls in the group which came heavy in first comparison (2nd comparison)
   If equal
       Return the uncompared ball
   Else
       Return the ball that is heavier

In fact the above algorithm works in every case where the number of balls is 3^n for n>1 with one additional comparison.

e.g.
For 27 balls this can be done in 3 steps.
For 81 balls this can be done in 4 steps.

Just group the balls in 3 groups. i.e. 27/3 which reduced it to the original problem.

- Expressions October 27, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

three and three first.Then if one side is heavier, take that side and put 1 ball on each. If one side is heavier, then that is the ball. If the two sides are equal, then the leftover ball is heavy.

If on the 3-3 balance, the two sides are equal, then take the leftover side and do the 1-1 shown
above.

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

Why didn't you state that it would be measured on a balance scale i.e. by comparison?

- Anon March 14, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1) take 4 balls on each side. Measure. If they are equal, the 9th ball you left out is the heavy one.
2) Otherwise split the heavy 4 group into two groups of two balls each and measure again.
3) Now drop the two balls from the heavy two group, the heavy one will land on the ground first.

LOL

- Anonymous March 17, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

take 4 balls on one side of measurement and another 4 balls on another side , then if equal means the 9 th one is heavy ...if the measurement is unequal.take the heaviest side and split into two and find which is heavy..

- mohamed rhiyassuddin October 30, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Well, you would have to do 3 comparisons like that, because so 4-4 is 1st.
and then if you go to the 2nd comparison,2-2, and if one side is heavier than the other, you would have to do a third measurement to do 1-1.

- Anonymous October 31, 2013 | Flag
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.


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