int __get_depth(node* root) { if (root == NULL) return 0; return 1 + max(__get_depth(root->lchild), __get_depth(root->rchild)); // return 1 + MAX(__get_depth(root->lchild), __get_depth(root->rchild)); // return 1 + (((__get_depth(root->lchild)) > (__get_depth(root->rchild))) ? (__get_depth(root->lchild)): (__get_depth(root->rchild))) }
static size_t __get_depth(const struct bnode_info *bnode) { if (bnode == NULL) { return 0; } else { size_t ldepth = __get_depth(bnode->lchild); size_t rdepth = __get_depth(bnode->rchild); if (ldepth > rdepth) { return ldepth + 1; } else { return rdepth + 1; } } }
int get_depth(bintree* tree) { return __get_depth(tree->root); }
static size_t btree_get_depth(const struct btree_info *info) { assert(info != NULL); return __get_depth(info->root); }