Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
The very basics
3. Recursion explained: real world examples
Infinite looping
Processing graphs with recursive CTEs


Let's get started. You might, or might not, have heard about recursion before. In either case, it's good to clarify what it is first.

Is there recursion in real life? Yes, there is. Take a good look at the Romanesco broccoli shown below. Its cones are made of smaller cones which are, in turn, made of yet smaller cones that are made of even smaller cones, etc.


Another example could be the famous Russian matryoshka dolls. If you open the biggest doll, you will see a smaller one. Once the smaller one is opened, you can see yet a smaller one, which in turn has another smaller doll inside itself.


In each case, we can say that a pattern repeats itself. Formally speaking, recursion takes place when something is defined in terms of itself. A Romanesco broccoli cone is a cone made of smaller Romanesco broccoli cones. A matryoshka doll is a doll that holds a smaller matryoshka doll.


Click Next exercise to continue.