Solve question 2 of assignment 4