Homework 4 for Data Structures and Algorithms 2