Answers for "counting nodes in binary search tree"

0

counting nodes in binary search tree

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);
    }
Posted by: Guest on November-12-2021

Code answers related to "counting nodes in binary search tree"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language