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

write a C++ program for booking using constructor and destructor.

2055


What is the significance of classes in oop?

592


What is object and example?

606


What causes polymorphism?

577


What is the example of polymorphism?

562






What is the real time example of encapsulation?

602


What is and I oop mean?

624


What is use of overloading?

612


What is object in oop with example?

708


What is balance factor?

589


What is the renewal class?

2171


What is the point of oop?

660


What is the highest level of cohesion?

581


What is abstract class in oop?

538


#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

2070