The sample output is correct


i think the sample output is correct while many of comments say it is wrong

   7                10
  2       8

the above illustration is a binary search tree and when traversed in preorder sequence it would give
[7 7 10 10 9 5 2 8]
correct me


you are forgetting the basic concept of BST i.e. the left subtree should have values less than or equal to the root node and the right subtree should have the values greater than the root node, but here you have nodes with values 5 and 2 in the right subtree of the root node, which is not possible. Thats why the sample output is wrong.


Oops such a silly mistakešŸ˜…