Solutions to other chapters:
Java Methods A & AB:
Object-Oriented Programming and Data Structures
Answers and Solutions to Exercises
Chapter 4
1. |
|
 |
3. |
|
 |
14. |
|
If n = 0, no radioactive coins found.
If n = 1, test the coin.
If n > 1, split the bag into two approximately equal bags.
Try to find the radioactive coin in the
first bag.
If not found, try to find the
radioactive coin in the second bag. |
15. |
|
If you have three coins, compare the weights
of any two.
If equal, the third one is the fake;
otherwise the lighter one is the fake.
For 3n
coins, split them into three groups of 3n-1
coins in each group.
Compare the weights of any two groups.
If equal, the fake is in the third group; otherwise it
is in the lighter group.
Look for the fake in the
identified group of 3n-1
coins using the same method. |
|