## 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.

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

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

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

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

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

3 comparisons.

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

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

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

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

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

Nayan is correct

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?

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

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

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

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)

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

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??

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

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.

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

Comment hidden because of low score. Click to expand.
-1
of 1 vote

Divide and conquer
2^3 - so within 3 measures

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

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

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.

### 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.