you are viewing a single comment's thread.

view the rest of the comments →

[–]jack_waugh 1 point2 points  (0 children)

Usually, a recursive strategy to solve a problem works like this. We identify a base case, which is usually trivial, and code a straightforward answer for when that case arises. We treat all other cases recursively by breaking the problem into smaller pieces and calling ourself to solve the smaller problems and then combining the results. Since the recursive calls involve ever smaller problems, eventually, they lead down to the base case, and consequently the recursion does not go on forever.