A Picture is Worth 1,500 Words

Mike Mbea
2 min readFeb 14, 2021

In programming we many concepts,but today we will learn about “Recursion”,but first let’s talk about function call or function invocation

Function call or fucntion invocation

When we call a function, an execution contexte gets placed on the execution stack.

What is a stack?

A stack is a type of data structure in programming language that operates on a “Last In,First Out”(LIFO) basis.An item is pushed onto a stack to add to it, and an item is “popped” off the stack to remove it.

Recursion

So what is a recursion or recursive function?

The concept of recursion happen when,a function call itself within its own definition.It calls itself over and over again until a base condition is met that break the loop.

Some pros of recursion:

  • Can reduce time complexity
  • Can add clarity and reduces the time needed to write and debug code

Some cons of recursion:

  • it use more memory : because the function has to add to the stack with each recursive call and keep the values there until the cak is finished
  • can be slow : if not implemented correctly it can be much slower than iteration.

In conclusion,i will say that the concept of recursion just look similar to are life,you live everyday until you reach something that marks your end of life.

--

--