774 views
2 votes
2 votes
if two identical elements are present in BST then how inorder can give sorted array as output ?
for ex. if 50,30,45,35,56,58,74,50,15 are inserted to make BST.

2 Answers

Best answer
2 votes
2 votes

Most specify left children as <= and right children as >. Practically speaking, a BST which allows either of the right or left children to be equal to the root node, will require extra computational steps to finish a search where duplicate nodes are allowed.

please see this link also - 

REF : http://stackoverflow.com/questions/300935/are-duplicate-keys-allowed-in-the-definition-of-binary-search-trees

selected by
0 votes
0 votes
if two identical elements are present in BST then how inorder can give sorted array as output ?
for ex. if 50,30,45,35,56,58,74,50,15 are inserted to make BST.

if any condition like this will come then the element which ill present  in left will print first and then middle or right as per elements present in tree

Related questions

1 votes
1 votes
1 answer
3
s_dr_13 asked Mar 10, 2019
2,692 views
Consider the following binary tree with root at level 0. What is the internal path length for the above tree?31142932