How to Build a Binary Search Tree with Given Data?

  • Context: MHB 
  • Thread starter Thread starter Henry R
  • Start date Start date
  • Tags Tags
    Binary Search Trees
Click For Summary

Discussion Overview

The discussion revolves around constructing a Binary Search Tree (BST) using a specific set of data points: 30, 40, 50, 60, 10, 20, 55, and 15. Participants are exploring the insertion process and the resulting structure of the tree.

Discussion Character

  • Technical explanation, Conceptual clarification, Debate/contested

Main Points Raised

  • Some participants propose that the first element, 30, should be the root of the BST.
  • It is noted that 40, being greater than 30, should be placed in the right subtree.
  • One participant questions the placement of 55 in relation to 40, suggesting a potential misunderstanding of the BST properties.
  • Another participant acknowledges the confusion regarding the placement of 55, indicating an error in the earlier reasoning.

Areas of Agreement / Disagreement

There is no consensus on the correct structure of the BST, as participants express differing views on the placement of certain nodes, particularly 55 in relation to 40.

Contextual Notes

Participants have not fully resolved the implications of the BST properties on the placement of nodes, and there are unresolved questions regarding the insertion order and resulting tree structure.

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: 130
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: 141
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: 116
How is 55 smaller than 40?
 
Bacterius said:
How is 55 smaller than 40?

Yeah! Sorry for that.
 

Similar threads

  • · Replies 13 ·
Replies
13
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
14
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K