Solutions to other chapters:
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26  
Java Methods Home Page Skylight Publishing



Java Methods A & AB:
Object-Oriented Programming and Data Structures

Answers and Solutions to Exercises

Chapter 4

1.  
3.  
7.   15
11. (b) E
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.

Copyright © 2006 by Skylight Publishing