只使用指向二叉树的根的一个指针T,计算T中节点的个数,T中树叶的片数,T中满节点的个数
2016-04-23 20:21
357 查看
数据结构与算法分析——c语言描述 练习4.28 答案
int countNodes(AvlTree t) { if (t == NULL) return 0; return countNodes(t->left) + countNodes(t->right) + 1; } int countLeaves(AvlTree t) { if (t == NULL) return 0; else if (t->left == NULL&&t->right == NULL) return 1; else return countLeaves(t->left) + countLeaves(t->right); } int countFull(AvlTree t) { if (t == NULL) return 0; else if (t->left &&t->right) return countFull(t->left) + countFull(t->right) + 1; else return countFull(t->left) + countFull(t->right); }
相关文章推荐
- 个人冲刺02
- linux Shell编程
- java 基础题 时间换算
- Node.js Web模块
- 机房收费系统——项目开发计划书
- 第八周学习进度条
- EasyUI DateBox 按钮自定义添加功能
- jQuery对象与DOM对象的区别
- Node.js工具模块
- 浙大 PAT Advanced level 1008. Elevator
- Unity脚本执行顺序
- 编程之美之子数组和的最大值(二维)
- React Native官方实例UIExplorer项目(for android)运行遇到的问题
- 第九周项目四 人数不定的工资类
- Node.js全局对象
- bzoj4546 codechef XRQRS
- matlab保存图片的四种方法&&遇到的一些问题
- 常用的Eclipse快捷键
- 第八周作业
- JMS基础知识