Data Structures, Algorithms, & Applications in C++
Chapter 15, Exercise 49
(a)
(b)
An example follows.