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

What is oops in programming?

558


How to use CMutex, CSemaphore in VC++ MFC

4318


How long to learn object oriented programming?

553


Plese get me a perfect C++ program for railway/airway reservation with all details.

3416


What is object in oop?

669






Are polymorphisms mutations?

687


#include #include #include #include void select(char *items, int count); int main(void) { char s[255]; printf("Enter a string:"); gets(s); select(s, strlen(s)); printf("The sorted string is: %s.\n", s); getch(); return 0; } void select(char *items, int count) { register int a, b, c; int exchange; char t; for(a = 0; a < count-1; ++a) { exchange = 0; c = a; t = items[ a ]; for(b = a + 1; b < count; ++b) { if(items[ b ] < t) { c = b; t = items[ b ]; exchange = 1; } } if(exchange) { items[ c ] = items[ a ]; items[ a ] = t; } } } design an algorithm for Selection Sort

2055


What polymorphism means?

610


What is overriding in oop?

539


How Do you Code Composition and Aggregation in C++ ?

24183


What is polymorphism in oops with example?

522


What are main features of oop?

621


Is data hiding and abstraction same?

561


What is the difference between a constructor and a destructor?

600


What is abstraction in oops with example?

759