Coin Problem

You are given 9 gold coins that look identical. One is
counterfeit and weighs a bit greater than the others, but
the difference is very small that only a balance scale can
tell it from the real one. You have a balance scale that
costs 25 USD per weighing.

Give an algorithm that finds the counterfeit coin with as
little weighting as possible. Of primary importance is that
your algorithm is correct; of secondary importance is that
your algorithm truly uses the minimum number of weightings
possible.

HINT: THE BEST ALGORITHM USES ONLY 2 WEIGHINGS!!!



Coin Problem You are given 9 gold coins that look identical. One is counterfeit and weighs a b..

Answer / pawan jain

1. Divide the coins in 3 groups of 3 coins each
2. Put 2 groups in the weighing scale
3a. If both the groups weigh equal
1. Pick 2 coins from the 3rd group and put in weighing scale
2. If they weigh equal, the 3rd coin is counterfeit.
Else the coin which weigh more is counterfeit
3b. If they do not weigh equal, pick the group with more
weight and do steps 3a1 and 3a2.

Is This Answer Correct ?    40 Yes 13 No

Post New Answer

More C++ Code Interview Questions

Faster Computers Suppose you have a computer that requires 1 minute to solve problem instances of size 1000. What instance sizes can be run in 1 minute if you buy a new computer that runs 1000 times faster than the old one, assuming the following time complexities T(n) for our algorithm? (a) T(n) = O(n). (b) T(n) = O(n3). (c) T(n) = O(10n).

1 Answers   Qatar University,


How can I Draw an ellipse in 3d space and color it by using graph3d?

0 Answers  


write a program using virtual function to find the transposing of a square matrix?

0 Answers  


what is virtual constroctor ? give an exam for it?-(parimal dhimmar)

2 Answers  


write a program to convert temperature from fa height into celcius and vise versa,use modular programming

0 Answers   Jomo Kenyatta University,






Show by induction that 2n > n2, for all n > 4.

2 Answers   Karvy, Qatar University,


what is the diffrence between ++x , x++ pleaaaaase ???

7 Answers  


1. Write a program using one dimensional array that calculates the sum and average of the five input values from the keyboard and prints the calculated sum and average.

2 Answers  


what is the difference between int &r and int& r

3 Answers  


A suduco given & u hv 2 check if it is incomplete(blanks left),or correct or incorrect

0 Answers  


Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)

0 Answers   iGate,


Implement a command console for changing settings on a particular object. The command console should allow you to enter a string and will return the response (very similar to a terminal session). The commands are as follows: SET propertyname=newvalue will change the target object’s member named “propertyname” to have a value equal to “newvalue”. If the input value is incompatible (i.e. an int being set to a string), print out an appropriate error message. GET propertyname will print out the current value of the target object’s member named “propertyname”. GET * will print out a list of all target object members and their current values. The system should be extensible for future commands and should accept an arbitrary object, such that another developer could insert another object into the system and rely on the command console to get and set the properties correctly.

0 Answers   ABC, Guidance Software,


Categories