Trace the tree-traversal function


Discussion:

Q: Trace the following tree-traversal function, f(), and describe its action:

template
int f(tnode *t)
{ int n = 0, leftValue, rightValue;

if (t != NULL)
{
if (t ->left != NULL || t->right != NULL)
n++;
leftValue = f(t->left);
rightValue = f(t->right);
return n + leftValue + rightValue;
}
else
return 0;
}

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Trace the tree-traversal function
Reference No:- TGS01937580

Now Priced at $20 (50% Discount)

Recommended (98%)

Rated (4.3/5)