The Gateway to Computer Science Excellence
+2 votes
176 views
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.
in DS by (19 points) | 176 views

2 Answers

+2 votes
Best answer

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

by Boss (10.5k points)
selected by
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
by Active (4k points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,375 answers
198,513 comments
105,290 users