Create a program that traverses a tree full of nodes and calls a function when it reaches a leaf node.
void callF(Node* root )
{
if(root ==NULL) return;
if(root->left) callF(root->left, fun);
if(root->right)callF(root->right, fun);
if(!root->left && !root->right)
fun();
return;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment