We have a scale and 7 balls. 1 ball is heavier than all the
rest. How to determine the heaviest ball with only 3
possible weighing attempts?

Answer Posted / simon y

Sorry guys, you failed the interview, and you got the
question wrong. It is what is the least number of
weighings - the answer is 2 not 3.
1) Take 2 random groups of 3 balls, compare them. If they
are the same you got lucky - the heavier ball is the one
you didn't weigh. If they are different you need step 2
2) Take the 3 heavier balls from weighing 1) and randomly
compare 2 of them. If one is heavier, that is the hevier
ball - if tehy are the same, then the one you didn't weigh
is the heavy one.

Is This Answer Correct ?    29 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to handle exception in c++, For example in a functions i am assigning memory to some variables and also in next instructions in am dividing one variable also. If this functions generates a error while allocating memory to those variable and also while dividing the variable if i divide by zero then catch block how it will identify that this error has cone from perticular instruction

1662


How many human genes are polymorphic?

583


What is a function in oop?

639


What are the 4 pillars of oop?

678


How do you use inheritance in unity?

595






What are the types of abstraction?

570


Why can't we have instance(stack) of a class as a member of the same class like eg.Class A{A obj;} as we can have self refential pointer

1629


There are two base class B1,B2 and there is one class D which is derived from both classes, Explain the flow of calling constructors and destructors when an object of derived class is instantiated.

1466


can we make game by using c

3444


when to use 'mutable' keyword and when to use 'const cast' in c++

1653


Why is encapsulation used?

585


What is abstract class in oop?

542


What is abstraction in oop?

646


What is difference between abstraction and encapsulation?

598


Is this job good for future? can do this job post grduate student?

1699