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
Can we create object of interface?
Whats is abstraction in oops?
State what is encapsulation and friend function?
What is the real time example of encapsulation?
What is purpose of inheritance?
How do you define a class in oop?
What is the difference between a mixin and inheritance?
Can we override main method?
Why is object oriented programming so hard?
write a programe to calculate the simple intrest and compund intrest using by function overlading
When not to use object oriented programming?
Which language is not a true object oriented programming language?
What is polymorphism programming?
What is meant by oops concept?
Why is abstraction used?