+ 4
Recursion means that a function is being called by itself repeatedly, until the base condition is reached. Conceptually it is very similar to a loop. Some problems can be solved with recursion very easily. You can do it in any programming language. There is a lesson about it in the C course. https://www.sololearn.com/learn/C/2930/
26th Dec 2019, 7:29 AM
Tibor Santa
Tibor Santa - avatar
+ 3
Tibor Santa , recursion can also be indirect when function a calls function b which then callls function a until a base case is reached. In this case it isnt expicitly calling itself but instead calling a functon that then calls it back.This can happen with more than two functions calling each other.
26th Dec 2019, 10:33 AM
Oluwaseun Familusi
Oluwaseun Familusi - avatar
+ 2
An interesting optimization and variation to the recursion logic is "Tail Recursion". Tail recursion can be implemented more efficiently than general recursion. When we make a normal recursive call, we have to push the return address onto the call stack then jump to the called function. This means that we need a call stack whose size is linear in the depth of the recursive calls. A recursive function is tail recursive when recursive call is the last thing executed by the function. Read more on these here: https://stackoverflow.com/questions/33923/what-is-tail-recursion https://www.geeksforgeeks.org/tail-recursion/ https://cs.stackexchange.com/questions/6230/what-is-tail-recursion
27th Dec 2019, 3:53 PM
Rajkumar Bhaduri
Rajkumar Bhaduri - avatar