![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
二叉树
dexianliang
这个作者很懒,什么都没留下…
展开
-
二叉树创建
1.结点添加的简单方式 #include <stdio.h> #include<stdlib.h> typedef struct node { int value; struct node *pLeft; struct node *pRight; }BinaryTree; BinaryTree *CreateTree() { BinaryTree *pRoo...原创 2018-07-31 14:23:18 · 1921 阅读 · 0 评论 -
二叉树递归遍历与非递归遍历
递归前序遍历 二叉树的创建就是递归的思想,每个结点都可以看作一个树。前序遍历是根->左->右的顺序,先打印根结点,分别将根的左右结点递归打印 #include <stdio.h> #include<stdlib.h> typedef struct node { int value; struct node *pLeft; struct node ...原创 2018-07-31 15:30:31 · 565 阅读 · 0 评论 -
计算二叉树叶子结点数
当二叉树的结点都没有左右孩子时,称之为叶子结点。采用递归方法计算叶子结点。 // 计算叶子结点数 void caculateLeafNum(BinaryTree * root, int *leafNum) { if(root ==NULL) return; if(root->pLeft ==NULL&&root->pRight ==NULL) { (*...原创 2018-07-31 17:00:40 · 16726 阅读 · 0 评论