Recursion is a concept which many find difficult to grasp at first, but it has its advantages. For starters, it can significantly reduce the runtime of certain algorithms, which makes the code more efficient.
Recursion also allows us to easily solve many problems related to graphs and trees. It is also important in search algorithms.
However, we need to be careful when using recursion. If we don’t specify an appropriate base case or update our arguments as we recurse, the program will reach infinite recursion and crash. The arguments passed to our recursive function are updated in each recursive call so that the base case can eventually be reached.