[Binary tree algorithm] while statistical leaf nodes and non-leaf nodes (recursively)

// while statistical non-leaf nodes and leaf nodes 10 
void the Count (BTNode * T, int & num1, int & num2) {
     IF (T == null ) return ;
     the else {
         IF (T-> lchild == null && T -> rchild == null ) { 
            num1 ++ ; 
        } the else { 
            num2 ++ ; 
        } 
        the Count (T -> lchild, num1, num2); 
        the Count (T -> rchild, num1, num2); 
    } 
}

Guess you like

Origin www.cnblogs.com/zzuuoo666/p/12083181.html