Algorithm HW 6b