Recursion explained ?

In this article we will break down all the concept you need to know before saying that you fully understand recursion. The goal is to talk about those concepts so that you can come up with your own definition of what recursion is ?.

Definition : Recur…


This content originally appeared on DEV Community and was authored by Ben Matt, Jr.

In this article we will break down all the concept you need to know before saying that you fully understand recursion. The goal is to talk about those concepts so that you can come up with your own definition of what recursion is ?.

Definition : Recursion is mostly described as a process that calls it self.
It can also be described by a function that calls it self.

Call Stack : In case we're calling a function or more multiple times in a program,
their is a thing called "Call Stack" that is an actual stack in witch functions are placed
on top of each other in terms of execution,
so the call stack can hold informations about all the functions that are placed on it.

So when using a recursive function what happen is we keep pushing the same function onto the "Call Stack".

What's the main structure of a recursive function ? :

A recursive function has two essential parts wich are the base case and a different input (or function argument).

1) The base case :
For the base case you can, think of it as a condition that causes the function to stop calling it self, in other words it stops the recursion.

2) Different input : Everytime a recursive function is being called, we need to make sure that the input aren't the same.

If one of the two or both are missing the process can resolve in what called a
"Stack overflow" forcing you to spend hours looking for answers on stackoverflow.com ?.


This content originally appeared on DEV Community and was authored by Ben Matt, Jr.


Print Share Comment Cite Upload Translate Updates
APA

Ben Matt, Jr. | Sciencx (2021-06-23T15:12:35+00:00) Recursion explained ?. Retrieved from https://www.scien.cx/2021/06/23/recursion-explained-%f0%9f%8e%89/

MLA
" » Recursion explained ?." Ben Matt, Jr. | Sciencx - Wednesday June 23, 2021, https://www.scien.cx/2021/06/23/recursion-explained-%f0%9f%8e%89/
HARVARD
Ben Matt, Jr. | Sciencx Wednesday June 23, 2021 » Recursion explained ?., viewed ,<https://www.scien.cx/2021/06/23/recursion-explained-%f0%9f%8e%89/>
VANCOUVER
Ben Matt, Jr. | Sciencx - » Recursion explained ?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/06/23/recursion-explained-%f0%9f%8e%89/
CHICAGO
" » Recursion explained ?." Ben Matt, Jr. | Sciencx - Accessed . https://www.scien.cx/2021/06/23/recursion-explained-%f0%9f%8e%89/
IEEE
" » Recursion explained ?." Ben Matt, Jr. | Sciencx [Online]. Available: https://www.scien.cx/2021/06/23/recursion-explained-%f0%9f%8e%89/. [Accessed: ]
rf:citation
» Recursion explained ? | Ben Matt, Jr. | Sciencx | https://www.scien.cx/2021/06/23/recursion-explained-%f0%9f%8e%89/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.