Glossary · Phase 7 · Software engineering
Recursion
A function solving a problem by calling itself on a smaller version of it, until it reaches a case simple enough to answer directly.
Try it now
Three frames for sum_to stack up before any of them can return. Then each one finishes, adding its n to the answer from below.
Learn it properly
Recursion, trees and graphs · Functions that call themselves, and the shapes most real data takes. About 35 minutes.
Other terms from the same lesson
- breadth-first search: Exploring a graph in rings: everything one step away, then two steps, and so on. It finds the path with the fewest hops.
- topological sort: An order of tasks in which each one comes after everything it depends on.
Never trained an AI?
Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.