Iterative vs. Recursive coding

Michael Torrie torriem at gmail.com
Sat Aug 21 19:08:18 CEST 2010


On 08/21/2010 03:03 AM, Steven D'Aprano wrote:
>> - there must be a condition where the recursion has to stop otherwise
>> the routine will continue to call itself infinitely.
>>   This is called the Base Case
> 
> I agree with this, although I've never heard the name "Base Case" before.

"Base Case" is indeed the formal term.  If I recall this term comes from
inductive mathematical proofs, upon which recursion is based formally.
In my introduction to computer data structures class we spent a lot of
time learning about induction and doing inductive proofs.  I always
hated them until one day when I was trying to teach recursion to a group
of freshmen and found myself relying on inductive proofs to demonstrate
that recursion indeed works.  For the uninitiated, recursion is often
thought about too deeply.



More information about the Python-list mailing list