Wrote the second algorithm for asymptotic analysis