当前位置:首页 > 题库 > 正文内容

CODE_COMPLETION:Binary tree - 13. Depth of binary tree

Luz1个月前 (05-10)题库24
Please write a function to find the depth of the binary tree.
####Function prototype
```c
int BinTreeDepth(const TNODE *root);
```
Note: ` root 'is the root pointer of the binary tree, and the function value is the depth of the binary tree.
Declare the function in the header file * bintree. H * and write the function in the program file * bintree. C *.
*BinTree.h*
```c
......
int BinTreeDepth(const TNODE *root);
......
```
*BinTree.c*
```
......
/*The code you submit will be embedded here*/
```
####Adjudication procedure
*main.c*
```c
#include
#include "BinTree.h"
int main()
{
TNODE *r;
BinTreeCreate(&r);
BinTreeInput(&r);
printf("%d\n", BinTreeDepth(r));
BinTreeDestroy(&r);
return 0;
}
```
![ Title. JPG] (~ / d1f8b532-136b-4ec2-b86f-db91d936e735. JPG)
####Input sample
```in
EIBJ##H###DF#A##G#C##
```
####Output sample
```out
four
```







answer:If there is no answer, please comment
分享给朋友:

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。