write a c program to find the depth or height of a tree..txt

来自「It is an ebook about trees」· 文本 代码 · 共 26 行

TXT
26
字号
Write a C program to find the depth or height of a tree. 

Discuss it!          




#define max(x,y) ((x)>(y)?(x):(y))

struct Bintree{
    int element;
    struct Bintree *left;
    struct Bintree *right;
};

typedef struct Bintree* Tree;

int height(Tree T)
{
    if(!T)
        return -1;
    else
        return (1 + max(height(T->left), height(T->right)))
}
 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?