alg: hw#3 prob.1 bug-fix and new iterative version