0 votes 0 votes if the value is less the root then it will goto left subtree & if the value is greater than root then it will go right. 1)what we do if value = root??(for multiple time same values) 2) duplicate values are allowed?? DS binary-search-tree + – Hira Thakur asked Aug 21, 2017 Hira Thakur 342 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
2 votes 2 votes As per the popular implementation of BST, We do not consider trees with duplicate values for BST. We write algo for element < & > the root. It does not mean we can not handle duplicate values. One smart solution is, in tree node, allocate a field for count. struct node { int data; int count; // Counts number of nodes with equal data. struct node *left; struct node *right; } Ahwan answered Aug 21, 2017 Ahwan comment Share Follow See all 0 reply Please log in or register to add a comment.