Oracle Interview Question for Software Engineer / Developers


Team: Java Developers
Country: United States
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
10
of 12 vote

It can be done in 2 measures:
Divide the 8 balls in 3 sets of 3,3,2.
Measure1: Weigh Set1 against Set2 => From here you can determine whether the heavier one belongs to Set1 or Set2 or Set3(if weights are equal).
Measure2: If you are left with Set3, measure the two balls against each other. Else if you are left with Set1/Set2, weigh two of the balls from that set against each other and you can determine whether one of them is heavier or the 3rd is actually heavier.

- -- March 14, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

suppose the wieght is 1,2,3,4,5,6,7,8,
and set is s1{1,8} s2{2,3,4} s3{6,7,8}

then s1 is eleminated which have heavier weight 8

- Anonymous June 20, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

The solution stated at the top is correct. Out of the 8 balls, ONLY ONE of them is heavier.

- Sandeep Mathias July 31, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 2 vote

3 comparisons.

4,4 ==> 2,2 ==> 1,1

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

Nayan is correct...it can be done in 2 steps..

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

with 2 steps it can be done... As nayan answer is correct

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

Nayan is correct

- anonymous March 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Nayan's answer is fine, but pls clarify my doubt. Lets say we are left with set1/set2. So, in measure2, what if the two balls are of same weight in either of the sets. Then we need take that ball in that set and do one more comparison with the 3rd ball to find the heavier one right?
Hope it make sense. So, is it not totally 3 steps?

- San March 18, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

In case u happen to select 2 balls from set 1/set2 which weigh the same,the third ball left in that set is the heavier one,so nayan is correct

- Anonymous March 18, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

it can be done in two measures
lets divide balls as (3 3 2)
take set (3,3)
case a) either balls are equal ( implies remaining 2 contains the heavier one)
case b) not equal,then take the heavier lot of 3 balls and divide them as (1,1,1). You can the heavier ball in just one step

so it is just 2 steps

case i)repeat the process as steps a) and b)

- Raman April 06, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

in (1,1,1) if first and second are compared and if one is heavier then there should be another comparision vt third ball right??

- Anonymous May 06, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

No need bro. If one of any two balls in a set is heavier than the other it would implicitly mean that, the ball in picture is the bulkiest one.

- Pavan Dittakavi May 08, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Its absolutely in 2 comp as stated in first solution...
s1(1,1,1),s2(1,1,2),s3(1,1)
compare s1 and s2(COMP-1)
s2 is big so compare s2[0]and s2[1](COMP-) both equal so s2[2] is hevier

- NAX June 04, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Divide and conquer
2^3 - so within 3 measures

- whizz.comp March 14, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

no brother it can be done in 2 time measurement...

- abh007 July 26, 2012 | Flag


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