How to Build a Binary Search Tree with Given Data?

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
6 replies · 2K views
Henry R
Messages
25
Reaction score
0
Draw a Binary Search Trees (BST) produced when data containing 30,40,50,60,10,20,55,15 is inserted one by one.

Thanks.
 
on Phys.org
Henry R said:
Draw a Binary Search Trees (BST) produced when data containing 30,40,50,60,10,20,55,15 is inserted one by one.

Thanks.

Note that every node on the right subtree has to be larger than the current node and every node on the left subtree has to be smaller than the current node.
 
evinda said:
Note that every node on the right subtree has to be larger than the current node and every node on the left subtree has to be smaller than the current node.

This is ...View attachment 3676
 

Attachments

  • Binary tree.PNG
    Binary tree.PNG
    6.4 KB · Views: 147
Henry R said:

Since the data is inserted one by one, $30$ has to be the root.
$40$ is greater than $30$, so it has to be at the right subtree.
So, at the beginning it should be like that:

View attachment 3677Can you continue? (Thinking)
 

Attachments

  • m.png
    m.png
    799 bytes · Views: 162
evinda said:
Since the data is inserted one by one, $30$ has to be the root.
$40$ is greater than $30$, so it has to be at the right subtree.
So, at the beginning it should be like that:

https://www.physicsforums.com/attachments/3677Can you continue? (Thinking)

sure.View attachment 3679
 

Attachments

  • b.PNG
    b.PNG
    9.4 KB · Views: 132
How is 55 smaller than 40?
 
Bacterius said:
How is 55 smaller than 40?

Yeah! Sorry for that.