Recursion

ITEC 4400/2160 Python Programming for Data Analysis,
Cengiz Günay

(License: CC BY-SA 4.0)

Prev - Errors and Exceptions, Next - Object Oriented Programming


(click to read more)

What is recursion

  • Reusing a function
  • Calling itself
  • Similar to a loop
  • But not linear, instead it could be exponential

Why recursion

What is the advantage over loops?

  • Divide-and-conquer type problems
  • Tree search
  • Sorting
  • etc.

Classic example: factorial


(click to read more)

Home