Ch. 5 alg. done