The following three items are written by me.
Static int node_count (const TREE tree) <br/>{< br/> int the_number_of_left_subtree = 0, the_number_of_right_subtree = 0, the_number_of_node = 0; </P> <p> If (tree! = NULL) <br/>{< br/> the_number_of_left_subtree = node_count (tree-> left); <br/> the_number_of_right_subtree = node_count (tree-> right ); <br/> the_number_of_node = the_number_of_left_subtree + the_number_of_right_subtree + 1; <br/>}</P> <p> return the_number_of_node; <br/>}</P> <p> static int leaf_count (const tree) <br/> {<br/> int the_number_of_left_subtree = 0, the_number_of_right_subtree = 0, the_number_of_leaf = 0; </P> <p> If (tree! = NULL) <br/>{< br/> the_number_of_left_subtree = leaf_count (tree-> left); <br/> the_number_of_right_subtree = leaf_count (tree-> right ); <br/> the_number_of_leaf = rows + rows; <br/> If (0 = rows & 0 = the_number_of_right_subtree) <br/> the_number_of_leaf ++; <br/>}</P> <p> return the_number_of_leaf; <br/>}</P> <p> static int full _ Count (const TREE tree) <br/>{< br/> int Limit = 0, the_number_of_right_subtree = 0, the_number_of_full_node = 0; </P> <p> If (tree! = NULL) <br/>{< br/> the_number_of_left_subtree = full_count (tree-> left); <br/> the_number_of_right_subtree = full_count (tree-> right ); <br/> If (the_number_of_left_subtree! = 0 & the_number_of_right_subtree! = 0) <br/> the_number_of_full_node + = the_number_of_left_subtree + the_number_of_right_subtree + 1; <br/> else if (tree-> left! = NULL & tree-> right! = NULL) <br/> the_number_of_full_node ++; <br/>}</P> <p> return the_number_of_full_node; <br/>}
The following three answers are provided, which is embarrassing.
Static int new_node_count (const TREE tree) <br/>{< br/> If (null = tree) <br/> return 0; <br/> return 1 + new_node_count (tree-> left) + new_node_count (tree-> right ); <br/>}</P> <p> static int new_leaf_count (const tree) <br/>{< br/> If (null = tree) <br/> return 0; <br/> else if (null = tree-> left & null = tree-> right) <br/> return 1; <br/> return new_leaf_count (tree-> left) + new_leaf _ Count (tree-> right); <br/>}</P> <p> static int new_full_count (const tree) <br/>{< br/> If (null = tree) <br/> return 0; <br/> return (tree-> left! = NULL & tree-> right! = NULL) + new_full_count (tree-> left) + new_full_count (tree-> right); <br/>}
Although I understand it, I can't write it by myself. To sum up some experience, this recursive function mostly uses return...