Solve question 3 of assignment 4