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 override main method?
How is polymorphism achieved?
How to call a non virtual function in the derived class by using base class pointer
State what is encapsulation and friend function?
write string class as your own class in java without using any built-in function
i got a backdoor offer in process global,Bangalore..Can i work with it?
What is interface? When and where is it used?
write a program that takes input in digits and display the result in words from 1 to 1000
What are the two different types of polymorphism?
What is the purpose of enum?
write a code for this. serial_number contained in the header of the file will be read , if this serial number is less than a previous serial number within a successfully processed file, or is the same as another serial number within a successfully processed file, or if the field contains anything other than 7 digits, then the file must error with the reason ‘Invalid SERIAL_NUMBER’.
What are the benefits of oop?
What is interface in oop?
Where You Can Use Interface in your Project
What is difference between data abstraction and encapsulation?