added algo4 for homework 2