When to use and avoid recursionΒΆ
When to use recursion: - When we can easily break down a problem into similar subproblems. - When we are ok with extra overhead (both time and space) that comes with it. - When we need a quick working solution instead of an efficient one.
When to avoid recursion: - If the response to any of the above statements are NO, we should not go with recursion.