0
28kviews
What is binary search tree? Explain with an example
1 Answer
written 8.2 years ago by |
A binary search tree, also known as ordered binary tree is a binary tree wherein the nodes are arranged in a order. The order is :
a) All the values in the left sub-tree has a value less than that of the root node.
b) All the values in the right node has a value greater than the value of the root node.
c) The same rule is carried forward to all the sub-tree in tree.
Since the tree is already ordered, the time taken to carry out a search operation on the tree is greatly reduced as now we don’t have to traverse the entire tree, but at every sub-tree we get hint where to search next.
Consider an example. We need to insert the following elements in a binary tree:
$$48,2,98,12,56,32,4,6$$