chap 1 problem 8 - Sahini's data structures book