Java : Count even values in a Binary Search Tree recursively
- by user307682
Hi,
I need to find out how many even values are contained in a binary tree.
this is my code.
private int countEven(BSTNode root){
if ((root == null)|| (root.value%2==1))
return 0;
return 1+ countEven(root.left) + countEven(root.right);
}
this i just coded as i do not have a way to test this out. I'm not able to test it out at the moment but need an answer so badly.
any help is deeply appreciated.