Consider the following recursive algorithm: int f(n) { if ( n
No answer yet for this question.
Ask a Tutor
Question:
Consider the following recursive algorithm:
int f(n)
{
if ( n <= 4 ) return n
int sum=f(n-3)
if f(n-1) < f(n-2)
return sum + n
else return sum - 1
};
Draw the recursion tree for f(7). In your drawing, draw all subtrees even though some of them may be identical. Show the returned values for each recursive call. In particular, what is the value returned for f(7)?
Related Book For
Computer Organization and Design The Hardware Software Interface
ISBN: 978-0124077263
5th edition
Authors: David A. Patterson, John L. Hennessy
Posted Date: