## Oracle Interview Question

Software Engineer / Developers**Team:**Java Developers

**Country:**United States

**Interview Type:**In-Person

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

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?

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

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)

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

It can be done in 2 measures:

- -- March 14, 2012Divide 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.