homework from Practise of Data Structure and Algorithm