Recursion
A recursive solution calls itself with a smaller or simpler input. Every recursive algorithm needs a base case that can be answered directly and a recursive case that moves toward that base case.
The intake batch uses a loop rather than recursion. The help desk case study will need the recursive idea later when a specialist explores related reports, because relationships can lead to more relationships. Seeing that recursion is not needed for the current step is itself a useful design decision.
function count_items(items):
if items is empty:
return 0
return 1 + count_items(items without its first item)
The base case prevents infinite calls. The recursive case must reduce the remaining work; otherwise the function may never finish.
Natural uses
Recursion fits nested or hierarchical data, including folders and divide-and-conquer algorithms. It can express these relationships clearly, but each call uses call-stack space and very deep recursion may be unsafe.
Choose a loop when the work is a straightforward stream of events. Choose recursion when the data itself has a recursive shape.