Added comments with algorithm complexity