Homework of algorithm