Monday, 14 October 2013
Recursion
In the previous post I talked about OOP. The main advantages of the OOP
paradigm is that it offers data encapsulation and polymorphism. Data
encapsulation separates interface from implementation and polymorphism
lets a whole system of data behave as one. A competing language design
paradigm is 'functional programing'. In this framework objects have no
notion of identity or mutable state. The consequence of this last
feature is heavy use of recursion. Recursion is the idea that we can
solve a big problem by breaking them down into smaller, self-similar, subproblem.
Therefore recursive functions take in the return value of their own
return call (recursive call). Recursion is related to mathematical
induction and in the most simple case a recursive needs a base case and a
recursive case. Base case produces a result without recurring and
recursive case divides the problem into a smaller subproblem.
The base case is sometimes called the terminating case and the job of
the recursive case is to breakdown the problem such that the terminating
case is eventually reached and the problem is solved.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment