A problem from Data Structures book