- A Russian nesting doll is a sequence of similar (except for the size) dolls inside of each other that can be opened.
- Each time you open a doll, a smaller version of the doll will be inside and you repeat the process until you reach the final doll, which will often contain a prize (like a piece of candy).
- A recursive function is like a Russian doll except even the size does not change.
- It will call itself repeatedly, like opening a doll repeatedly.
- But, as with the Russian dolls, there is a condition to avoid an endless loop; at a certain point there will be no recursive call anymore. That is analogous to the point where you find a prize inside of the smallest doll.
- In this metaphor, the smallest doll represents the base case in the recursive definition.
From: WOOLLARD, WILLIAM JOHN (2004), “The rôle of metaphor in the teaching of computing; towards a taxonomy of pedagogic content knowledge.”, University of Southhampton, School of Education, PhD Thesis, pg 128
Other Tips By: