Consider the following mystery method. Trace it for mystery(01101, 4) ; try to draw a tree of
Fantastic news! We've Found the answer you've been seeking!
Question:
Consider the following mystery method. Trace it for mystery("01101", 4) ; try to draw a tree of all function calls (you do not need to submit the tree, just briefly explain it and write the final result of calling mystery("01101", 4) . Give a high- level description of what the method does.
int mystery(string s , int last)
{
if(last<0)
return 0;
if(s.chart(last)=='0')
return 2*mystery(s,last-1);
return 1+2*mystery(s,last-1);
}
Related Book For
Numerical Methods With Chemical Engineering Applications
ISBN: 9781107135116
1st Edition
Authors: Kevin D. Dorfman, Prodromos Daoutidis
Posted Date: