📌  相关文章
📜  计算二叉搜索树中的节点 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:47.659000             🧑  作者: Mango

代码示例1
public int countNode(Node root){

        //base case
        if(root==null)
            return 0;

        //recursive call to left child and right child and
        // add the result of these with 1 ( 1 for counting the root)
        return 1 + countNode(root.left) + countNode(root.right);
    }