April 2024
Beginner to intermediate
500 pages
24h 20m
English
Before we look at the program used to draw the tree, we must first learn a little more about recursion. In computer science and mathematics, a recursive function is a function that calls itself.
A very simple, but erroneous, illustration of a recursive function is shown in Listing 9.1. The hello function prints the message "Hello World" and then calls itself again. If you ran this function in Python, the program would continue to call itself and print "Hello World" until Python crashed. Clearly, there is more to a successful recursive function than simply calling itself.
Listing 9.1 An erroneous recursive function
A more useful way of thinking ...
Read now
Unlock full access