problem 5 of chap 1 - Datastructures by sahini