0
votes

I have problems writing this method public int getHeight, where i have to find the height of the binary search tree, using recursion. The reason is that my main class, is made with private comparable mKey and private vertex mLeft, mRight, and mParent, instead of nodes. Would love some help.

1
Please post the relevant parts of your code - fdsa

1 Answers

0
votes
public int getHeight(Tree t, int depth)
{
    if(t == null){
        return depth;
    }
    else{
        return Math.max(getHeight(t.mLeft, depth + 1), getHeight(t.mRight, depth + 1))
    }
}

This returns the length of the deepest branch in the tree.

EDIT: call with getHeight(tree,0)