Added code, visualization, and final explanation for question 4