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
What are the 5 oop principles?
i=20;k=0;
for(j=1;k-i;k+=j<10?4:3)
{
cout< What is object in oop with example? What is the purpose of enum? 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. Can we create object of abstract class? Can you inherit a private class? Can a destructor be called directly? Is html an oop? What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems? what is difference between class template and template class? Why polymorphism is used in oops? Why is abstraction used? Question:
Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and
Monthly. An appointment has a description (for example, “see the dentist”) and a date
and time. Write a virtual function occurs_on(int year, int month, int day) that checks
whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of
Appointment* with a mixture of appointments. Have the user enter a date and print out
all appointments that happen on that date. What are objects in oop?