Created
December 21, 2014 23:50
-
-
Save arjunrao87/05693b687f6bad922b71 to your computer and use it in GitHub Desktop.
Height of a BST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int height( Node root ){ | |
if( root == null ){ | |
return 0; | |
} | |
int heightLeft = height( root.getLeftChild() ); | |
int heightRight = height( root.getRightChild() ); | |
return Math.max( heightLeft, heightRight ) + 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment