Data Structures, Algorithms, & Applications in Java
Chapter 16, Exercise 49
(a)
(b)
An example follows.