Skip to content

Instantly share code, notes, and snippets.

@sarahzhao25
Last active January 6, 2018 21:44
Show Gist options
  • Save sarahzhao25/41fa7849acce3b679050273498b229da to your computer and use it in GitHub Desktop.
Save sarahzhao25/41fa7849acce3b679050273498b229da to your computer and use it in GitHub Desktop.
Height function of a BST
BinarySearchTree.prototype.height = function(treeNode) {
return (treeNode === null) ? -1 : Math.max(this.height(treeNode.left), this.height(treeNode.right)) + 1;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment