Recursion
An imperative algorithm uses a series of commands to manipulate data. We use sequential commands with loops and iteration when writing code.
Read N pages = read page 1, read page 2, …, read page N.
A recursive algorithm is defined in terms of itself: the algorithm uses itself to solve the problem. Recursion is a top-down approach: the algorithm starts with a big problem and calls itself recursively on smaller problems. This suits Divide And Conquer strategies very well. A recursive algorithm can always be translated into an imperative version.
Read N pages = read page 1, read N minus 1 pages.
With recursion, one can describe infinity with a finite algorithm. Think about how fractals display intricate, infinite and beautiful structures from the simplicity of a recursive formula.
“The journey of a thousand miles begins with a single step.” — Lao Tzu