To alter the parameter to get to the base case, we typically reduce or modify the parameter (often an integer or a variable representing state) in a systematic way. This can involve subtracting one (in the case of recursive functions), reducing the size of a problem, or transitioning the problem into a simpler form that directly corresponds to the base case.
For example, in the context of recursion:
- If the parameter is an integer
n
, you might call the recursive function withn-1
orn/2
until you reach the base case that usually represents the smallest or simplest possible input (oftenn=0
orn=1
).
The key is to ensure that each step gets you closer to that base case.