Recursion

How to understand a recursion?

Recursion is a function to achieve the result with calling itself. For example, when doing the factorial, . Sometimes we can image it as a tree, a decision tree.

Space

Recursion is consuming the stack space in JVM or other programming stack. So we care how deep the recursion functions are going on and we need to set a smart terminate condition for recursion.

Time

Pruning! Pruning is important when doing a complex recursion function. We can avoid some unnecessary recursion by terminate it with smart condition.

results matching ""

    No results matching ""