1. Consider the following recursive function.
int mystery(int number)
{
if(number == 0)
return number;
else
return(number + mystery(number - 1));
}
a. Identify the base case.
b. Identify the general case.
c. What valid values can be passed as parameters to the function mystery?
d. If mystery(0) is a valid call, what is its value? If not, explain why.
e. If mystery(5) is a valid call, what is its value? If not, explain why.
f. If mystery(-3) is a valid call, what is its value? If not, explain why.
2. Consider the following recursive function:
void funcRec(int u, char v)
{
if(u == 0)
cout<else if(u == 1)
cout<(static_cast(v) + 1);
else
funcRec(u - 1, v);
}
a. Identify the base case.
b. Identify the general case.
c. What is the output of the following statement? funcRec(5, 'A');