Answer:
(a): The base case: if(n<1)
(b): The recursive statement: recur(n / 5)
(c): Parameter 10 returns 7
Explanation:
Given
The above code segment
Solving (a): The base case:
The base case is that, which is used to stop the recursion. i.e. when the condition of the base case is true, the function is stopped.
In the given code, the base case is:
<em>if(n<1)</em>
Solving (b): The recursive statement:
The recursive statement is the statement within the function which calls the function.
In the given code, the recursive statement is:
<em> recur(n / 5)</em>
<em />
Solving (c): A call to recur() using 10
The base case is first tested
if (n < 1); This is false because 10 > 1
So, the recursive statement is executed
<em>recur(n/5) +2=> recur(10/5)+2 => recur(2)+2</em>
2 is passed to the function, and it returns 2
if (n < 1); This is false because 2 > 1
So, the recursive statement is executed
<em>recur(n/5) +2=> recur(2/5)+2 => recur(0)+2</em>
2 is passed to the function, and it returns 2
<em />
if (n < 1); This is true because 0 < 1
This returns 3
So, the following sum is returned
Returned values = 2 + 2 + 3
Returned values = 7