I know there are many functions to be found out there where you can easily get the height of the Binary search tree by recursively calling the function and using the root of the node as the parameter every time for the left and right subtree. But what am I supposed to do when I won't be taking parameters on a Treap but it still return an int. I have been able to call other methods recursively but I am stopped on this one. Some help would be greatly appreciated!
This is what I have but I largely believe it's wrong
public int height()
{
if(temp == null)
return 0;
else
{
temp = temp.left;
temp = temp.right;
return Math.max(height(), height()) + 1;
}
}