Indirect recursion: Method A calls
method B that calls method A
Potentially can go on
forever (until memory
full - Stack Overflow
Very powerful construct
based on mathematical
induction.
Recursive programming
All loops can be implemented as recursive calls
int f(int x) { if ( x<1 ) {
return 0; } return x +
f(x-1); }
Inefficient in java, but core
concept in functional
programming
Programming recursively
When programming, "solve" a
problem by using another method
(call it before you implement it)
When this other method is
the calling method, you
have recursion.
Recursion is not a goal in itself
Recursive data structures (XML documents, file directories (called folders in windows), linked lists etc.)
are most easily handled with recursive functions.
Programming Language Concepts
Paradigms
Imperative
describes computation in terms of
statements that change a program
state
The term is used in opposition to declarative
programming, which expresses what the program
should accomplish without prescribing how to do it in
terms of sequences of actions to be taken
Logic
Popularized by Prolog
Based on predicate calculus
Starts with statements of facts –
parent(john, jake), parent(jake, jack)