Implement the Iterative algorithm.