二叉树求高度

int getdepth(BTreeNode* root)   // 修改单个节点的树高
{
    if (root == nullptr)
        return 0;
    int depthLeft = getdepth(root->left_child);
    int depthRight = getdepth(root->right_child);
    return 1 + max(depthRight, depthLeft);
}
void height(BTreeNode* root)
{
    if (root == nullptr) return;
    height(root->left_child);      //此处相当于遍历整个树进行求高度
    height(root->right_child);
    root->height = getdepth(root);
}

求高度后续遍历