When to Use Recursion?
In this lesson, we identify areas where recursion is used.
Nowadays, many programming languages such as Haskell, Scala, JavaScript, etc. use Functional Programming. An important concept of functional programming is recursion. Entire languages are now being based on recursion.
In general, problems that can be solved with a non-recursive code can also be solved by recursion. However, some problems can only be solved recursively.
It is important to note that even if it is possible to solve any problem with recursion, it does not mean that we should.
Let’s take a look at some pointers that will help us identify whether to use recursion or the conventional iterative method for solving a specific problem.
When to use Recursion?
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.