Function to get the count of leaf nodes in a binary tree
public virtual int LeafCount { get { return getLeafCount ( root ) ; } } public virtual int getLeafCount ( Node node ) { if ( node == null ) { return 0 ; } if ( node . left == null && node . right == null ) { return 1 ; } else { return getLeafCount ( node . left ) + getLeafCount ( node . right ) ; } }