Jul 10, 2009

Print all the paths in the tree

Print all the paths in the tree
foo(tree* root, int* arr, int idx)
{
if(!root) return;
arr[idx]=root->val;
if(!root->left&&!root->right){print arr; return;}//left node
foo(root->left,arr,idx+1);
foo(root->right,arr,idx+1);
}

No comments:

Post a Comment