problem 6 in chapter 1 - Sahini datastructures