From the course: Python: Recursion

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Recursion vs. iteration

Recursion vs. iteration - Python Tutorial

From the course: Python: Recursion

Start my 1-month free trial

Recursion vs. iteration

- [Instructor] In principle, you can turn every recursive algorithm into an iterative one and vice versa. A question which is often asked is, should I use recursion in production code? Some people will tell you never to, end of story. However, this is one of those situations where there is a difference between a guideline and a rule and rigid application of the rule can mean that some of the very real benefits of recursion are not leveraged. One of the things about recursion is that it can be hard for a newcomer to accept that a recursive solution to a problem is often much simpler than a non recursive one. Hopefully at this stage in the course, you can see how this could be the case. Given that for an employer development time is an expensive cost that they wish to minimize without compromising on quality. If you can provide a recursive solution to a problem that avoids the potential pitfalls, but which takes less time…

Contents