int sillyone(int n) { if (n <= 1) return n; else return sillyone(n-1) + sillyone
ID: 3616471 • Letter: I
Question
int sillyone(int n){
if (n <= 1)
return n;
else
return sillyone(n-1) + sillyone(n-1);
}
int sillytwo(int n)
{
if (n <= 1)
return n;
else
return 2 * sillytwo(n-1);
}
Output of sillyone(5) is
Output of sillytwo(5) is .
# of sillyone() invocations done as part of sillyone(5) executionis .
# of sillytwo() invocations done as part of sillytwo(5) executionis .
I believe the output of sillyone(5) is 8 and the output ofsillytwo(5) is also 8. Just want to verify.
I do need the answers to the 2nd part of the test - theinvocations.
Explanation / Answer
#include using namespace std; int two =0; /*one stores the numebr of invocationsof sillyone(), two stores the number of invocations of sillytwo()*/ int sillyone(int n) { one++; //increases if sillyone()is executed if (nRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.