Friday, 5 June 2015

tag removed - is there a name for this type of function ?

The class of functions you are describing are known as recursive. For example, the $sum$ function has the following recursive definition:



$sum(x_1) = x_1$



$sum(x_1, x_2, cdots x_{n-1}, x_n) = sum(x_1, x_2, cdots, x_{n-1}) + x_n$.



In this particular situation it was sufficient to know what $sum(x_1, x_2, cdots, x_{n-1})$ is to quickly compute $sum(x_1, x_2, cdots, x_{n-1}, x_n)$. However, in many other situations to compute $f(x_1, cdots x_n)$ you must know the solution to a large number of subproblems of $f$ to be able to compute $sum(x_1,cdots, x_{n})$ quickly. For example, $f$ may be defined recursively as:



$f(x_1) = g(x_1)$



$f(x_1, cdots, x_n) = f(x_1,x_2, cdots x_{frac{n}{2}}) + f(x_{frac{n}{2}+1}, cdots, x_n)$



A general technique from computer science that can be used to compute such functions is dynamic programming. Essentially a table is constructed that stores the solution to all subproblems (or perhaps just some subset of the subproblems which will be needed later) to the original. Since the solution to larger subproblems is constructed using the solutions to smaller subproblems you construct this table in order of increasing size.



EDIT: Dynamic programming is typically used when the solutions to the subproblems needed to compute $f(x_1, cdots, x_n)$ overlap. If they do not overlap a simple recursive definition will usually be simpler.

No comments:

Post a Comment