Height of the binary search tree is defined as the number of nodes in the longest path from the root node to leaf node.
You might also be interested in
Singly Linked List
Binary Search Tree in Python
Binary Search Tree in C++
Insert ,Search and Display Binary Search Tree
Print Leaf nodes of Binary Search Tree
Linked list in Python
In the above image one of the longest paths is 8 --> 10 --> 14 --> 13, containing 4 nodes hence the height of the binary search tree is 4.
One thing that should be noted is that a tree with only root node has height 1 and not 0.
In the following the height of the left and right subtree is compared and the larger value is returned.
C++ Program
You might also be interested in
Singly Linked List
Binary Search Tree in Python
Binary Search Tree in C++
Insert ,Search and Display Binary Search Tree
Print Leaf nodes of Binary Search Tree
Linked list in Python
Comments
Post a Comment