Update
This commit is contained in:
parent
edfdeccc52
commit
39b1169fbf
13 changed files with 55 additions and 14 deletions
|
@ -60,4 +60,6 @@ unsigned int factorial(unsigned int x)
|
|||
|
||||
How do the computers practically make recursion happen? Basically they use a [stack](stack.md) to remember states on each level of the recursion. In programming languages that support recursive function calls this is hidden behind the scenes in the form of [call stack](call_stack.md). This is why an infinite recursion causes stack overflow.
|
||||
|
||||
Another important type of recursion is **tail recursion** which happens when the recursive call in a function is the very last command. It is utilized in functional languages that use recursion instead of loops. This kind of recursion can be optimized by the compiler into basically the same code a loop would produce, so that e.g. stack won't grow tremendously.
|
||||
Another important type of recursion is **tail recursion** which happens when the recursive call in a function is the very last command. It is utilized in functional languages that use recursion instead of loops. This kind of recursion can be optimized by the compiler into basically the same code a loop would produce, so that e.g. stack won't grow tremendously.
|
||||
|
||||
Mathematical recursive functions find use in [computability](computability.md) theory where they help us (similarly to e.g. [Turing machines](turing_machine.md)) define [classes](class.md) of functions (such as primitive recursive and partial recursive) by "how strong of a computer" we need to compute them.
|
Loading…
Add table
Add a link
Reference in a new issue