求二叉树的深度
来源:互联网 发布:mongodb 连接数据库 编辑:程序博客网 时间:2024/06/10 18:31
#include<stdio.h>#include<stdlib.h>typedef struct BTNode{ struct BTNode *lchild,*rchild; int data;}BTNode,*btnode;void createBtree(btnode &T){ int t; scanf("%d",&t); if(t==0) T=NULL; else { T=(btnode)malloc(sizeof(BTNode)); T->data=t; createBtree(T->lchild); createBtree(T->rchild); }}int getDepth(btnode &T){ int LD,RD; if(T==NULL) return 0; else { LD=getDepth(T->lchild); RD=getDepth(T->rchild); return (LD>RD?LD:RD)+1; }}void main(){ btnode T; int depth; createBtree(T); depth=getDepth(T); printf("depth=%d\n",depth);}
0 0
- 求二叉树的深度
- 求二叉树的深度
- 求二叉树的深度
- 求二叉树的深度
- 求二叉树的深度
- 求二叉树的深度
- 求二叉树的深度
- 求二叉树的深度
- 求二叉树的深度
- 求二叉树的深度
- 求二叉树的深度
- 求二叉树的深度
- 求二叉树的深度
- 求二叉树的深度
- 求二叉树的深度
- 求二叉树的深度
- 求二叉树的深度
- 求二叉树的深度
- 继承,菱形继承,多态,虚拟继承,多虚拟继承,菱形虚拟继承
- CCPP资料
- 9. 使用Filter
- android自动弹出软键盘(输入键盘)
- 添加和删除元素:
- 求二叉树的深度
- Flume+Kafka+Storm的实时日志统计
- 发送短信验证码按钮的实现
- Linux 下 Gcc 生成和使用静态库和动态库详解
- Win7&win10无法远程的最佳解决方法
- 贪心算法 Problem Q 1016
- HTML基础
- 可恶的Eclipse 一天崩几百遍我都不惊诧
- fckeditor浏览服务器文件问题