Question

First of all I know this question has been asked multiple times so my apologies but I got lost when I thought of creating a BST for the word 'BERNER' with duplicates allowed .

So I know this might look like this, I'm half way done with it but I got confused when I think about placing N and R

     B
    / \
   E   R
  /   
 E   

Also I have some other questions

  1. In the above BST the first 'E' letter initially gets placed on the right side of the root node (B) due to E>B, but when we move on to 'R' it becomes the right node and 'E' becomes left node so I was thinking isn't that a violation of the BST rule since E > B, and it should also be a right node of 'B' ? Is this some kind of rule which I'm missing.

  2. Creating 'BERNER' without Duplicates

Any help/Suggestion will be appreciated. Please don't be tough on me. I'm a newbie to BST Concepts.

Was it helpful?

Solution

BST for BERNER, with consideration that there is no different to insert nodes to left or right when its value is equal to its parent

Binary Tree for BERNER (PLEASE PAY ATTENTION that There must be no duplicate nodes in BST), with consideration that there is no different to insert nodes to left or right when its value is equal to its parent.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top