MHB How to Build a Binary Search Tree with Given Data?

AI Thread Summary
The discussion focuses on constructing a Binary Search Tree (BST) from a sequence of numbers: 30, 40, 50, 60, 10, 20, 55, and 15. The initial point establishes that 30 is the root of the tree. Subsequent numbers are inserted based on the BST property, where each left subtree node is smaller than the current node and each right subtree node is larger. The participants clarify the placement of nodes, ensuring that 40 is positioned to the right of 30, and address a confusion regarding the placement of 55 in relation to 40. The conversation emphasizes the importance of adhering to the BST rules during the insertion process.
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.
 
Technology news 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: 109
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: 115
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: 100
How is 55 smaller than 40?
 
Bacterius said:
How is 55 smaller than 40?

Yeah! Sorry for that.
 
Back
Top