MicrolearnENPTES

Recursion

Lesson 18 of 20 · Algo.Micro

A function that calls itself on a smaller problem, and the cost of repeating work.

fib(n) = fib(n-1) + fib(n-2), with base cases fib(0) = 0 and fib(1) = 1. Without a base case the function would call itself forever.

Check yourself

What happens if a recursive function has no base case?

Do it in the browser: a real algorithms tool, a short mission and instant feedback. No install.

Start this lesson — free
← Dijkstra's shortest pathsDynamic programming →

All lessons · Algo.Micro