Add some comments to simple algorithm

Add comments to simple algorithm for easier understanding