A Binary Search Tree is a Data Structure in which
a) The left subtree of a node contains only those nodes with keys less than the parent node's key.
b) The right subtree of a node contains only those nodes with keys greater than the parent node's key.
c) The left and right subtree must each also be a binary search tree.
d) There must be no duplicate nodes.
| | | |
19 21 40 44
As can be figure out that, the Parent/Root node is 34. The elements to the left of it are smaller than 34 while on the right are bigger than that. The child nodes also follows the same pattern.
Advantage: Sorting and Search algorithms like in-order/post order/pre order traversal are very efficient.
Hope this helpsCrniranjanraj, if this helps please login to Mark As Answer. | Alert Moderator