Algorithm 1 HW5