求二叉树的高度/销毁一颗二叉树
2018-03-29 17:01
260 查看
int HeightOfBinatyTree1(BinaryTreeNode* pRoot) //二叉树的高度 { if (pRoot == NULL) return 0; int m = HeightOfBinatyTree1(pRoot->_pLeft); int n = HeightOfBinatyTree1(pRoot->_pRight); return (m>n)? (m+1):(n+1); } void Destory(BinaryTreeNode*& pRoot)//销毁二叉树 { if (pRoot == NULL) return ; if (pRoot->_pLeft) Destory(pRoot->_pLeft); if (pRoot->_pRight) Destory(pRoot->_pRight); delete(pRoot); pRoot = NULL; }
相关文章推荐
- day11之求二叉树的高度+销毁一颗二叉树+链表每K个节点之间逆序
- 求二叉树的高度/销毁一颗二叉树【每日一题】
- 求二叉树的高度和销毁一颗二叉树——题集九
- 二叉树--求二叉树的高度/销毁一颗二叉树
- 求二叉树的高度/销毁一颗二叉树【递归思想】
- 求二叉树的高度/销毁一颗二叉树-->Destroy(Node* root)
- 【每日一题-11】求二叉树高度/销毁一棵二叉树与链表翻转
- 【二叉树】二叉树的高度以及创建 销毁二叉树
- 每日一题之求二叉树的高度并销毁一棵二叉树
- 每日一题——求二叉树的高度,销毁二叉树
- 二叉树的【深/高度】【度为0/1/2的结点数】【遍历】【查找】【销毁】
- 假设二叉树采用链接方式存储,编写一个计算一颗二叉树t的高度的函数
- 二叉树的高度 、销毁、链表的翻转(k为一组、n-m 之间)两种实现、
- 二叉树的创建,遍历,求高度,算出节点数,算出叶子节点数,左右子树的交换,二叉树的销毁。
- 数据结构面试题/求二叉树的高度/销毁一棵二叉树-->
- 销毁一颗二叉树-->Destroy(Node* root)
- 二叉树——高度
- 二叉树的各种操作 先序 中序 后续 层次 遍历 求树高度 节点深度 知先序中序求后续 二叉排序树
- 输入一颗二叉树和一个整数,打印出二叉树中结点值的和为输入整数的所有路径。路径定义为从树的根结点开始往下一直到叶结点所经过的结点形成一条路径。
- 树:求二叉树的高度和叶子结点数量