January 2018
Intermediate to advanced
1204 pages
28h 27m
English
When designing a recursive solution for a problem, we need to do two things:
define the base case
define the rule for the general case
For example, if we want to print “Hello World” 100 times, we can do the following:
print “Hello World” once
print “Hello World” 99 times
Note that we do two things: First, we print “Hello World” once, which is easy to do. Then we reduce the size of the remaining problem to printing “Hello World” 99 times. In order to print “Hello World” 99 times, we print “Hello World” once, then we print “Hello World” 98 times. Continuing the same approach, to print “Hello World” 98 times, we print “Hello World” once, then we print “Hello World” 97 times, and ...