Added by 16 of our members. Recursion A novel by Blake Crouch. What if someone could rewrite your entire life?
This chapter is concerned with the close relationship between recursion and induction in programming. When defining a recursive function, be sure to write down a clear, concise specification of its behavior, then mentally or on paper give an inductive proof that your code satisfies the specification. What is a specification?
First, a base case is the condition that allows the algorithm to stop recursing. A base case is typically a problem that is small enough to solve directly. In the listsum algorithm the base case is a list of length 1. To obey the second law, we must arrange for a change of state that moves the algorithm toward the base case.
I vividly remember the day in college where my Introduction to Data Structures professor introduced the concept of recursion. And my brain promptly exploded. This was such a radical idea and I felt like a potato with legs trying to figure out what the hell was going on.
PaulHoule on July 23, parent favorite on: How recursion got into programming: a comedy of er Retric on July 23, The rational is vary reasonable.
Recursion is a concept most commonly encountered in programming. One example might be a Photoshopped image of a man holding a photograph of him holding the photograph of him holding the photograph…. In programming, a recursive routine is one that calls itself with different parameters; the routine calls itself to do a calculation that calls itself to do a calculation that calls itself… In the case of programming, the routine must have some way of determining when it has drilled deep enough down through enough recursive layers to reach the bottom; otherwise, it will keep recursing until it runs out of memory to hold all the intermediate states.