Added algorithm section for question 3