Finished the code for the linearly complex dynamic algorithm.