Chapter 4 upto alg1, fixed algorithmic error