Recursion
I’ve always had trouble visualizing recursion.
Recursive functions are functions that call themselves inside the function. As a computer programming technique, this is called Divide and Conquer and is key to the design of many important algorithms.
Recursion vs. Loops
Recursion and loops are equivalent structures. That is, any task you can achieve with one you can achieve with the other.
Recursion is most useful when you can break up your task into smaller subtasks.
I guess don’t think too much about the whole process. Break it down into subproblems.
- Think base case
- What is the next case and relationships between those cases?