<> one , Problem introduction

* A binary tree stored in a binary linked list is known , Write an algorithm to calculate the node number of a single child of a binary tree . Single child means that the node has only left children or only right children ( In fact, it is to find the degree as 1 Number of nodes )
<> two , Algorithm implementation
typedef struct Node { DataType data;// Data domain struct Node *leftchild;// Left subtree pointer struct
Node *rightchild;// Right subtree pointer }BiTreeNode;
Recursive implementation is particularly simple
// Calculate the binary tree as 1 Total number of nodes int leaf_1(BiTreeNode *T) { if (T==NULL) { return 0; } if ((T
->leftchild == NULL && T->rightchild != NULL) || (T->leftchild != NULL && T->
rightchild== NULL)) { return 1 + leaf_1(T->leftchild) + leaf_1(T->rightchild); }
return leaf_1(T->leftchild) + leaf_1(T->rightchild); }

©2019-2020 Toolsou All rights reserved,
about String How to create objects JavaScript Hundred refining into Immortals 1.15 Legendary Is MCU embedded , It's a cliche Resume the 13th session python Blue Bridge Cup html+css+js Make a simple website home page java Connect to the database to realize basic addition, deletion, modification and query VHDL——JK trigger Java of JDBC programming 3 4j It's not legal python expression _3+4j It's not legal Python expression .【linux】shell: ordinary shell Script exercise