Added code, visualization, and explanation for question 2