Thats the best I could come up but it still doesn't work cause it returns 1 even if there was more than one node that have two children.
int countTwoChildren(Node node)
{
if(node==null) {
return 0;
}
if(node.left!=null && node.right!=null) {
return 1;
}
return countTwoChildren(node.left) + countTwoChildren(node.right);
}
Can anyone find any error in above piece of code?