What is Binary Search Tree ?

Posted by Crniranjanraj under Others on 10/5/2015 | Points: 10 | Views : 238 | Status : [Member] | Replies : 1
In Data Structure, What is Binary Search Tree ? Explain with an example.




Responses

Posted by: Rajnilari2015 on: 10/11/2015 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 25

Up
0
Down
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.


         34
|
----------
| |
20 43
---- ----
| | | |
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 helps

--
Thanks & Regards,
RNA Team

Crniranjanraj, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response