int foo(tree* node, int min, int max, int& count)
{
if(!root) return;
if(root->val>min && root->val < max)
{
count++;
foo(node->left,min,max,count);
foo(node->right,min,max,count);
}
else if(root->val>max) foo(node->left,min,max,count);
else if(root->val < min) foo(node->right,min,max,count);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment