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
SUMMARY

The discussion focuses on constructing a Binary Search Tree (BST) using the data set 30, 40, 50, 60, 10, 20, 55, and 15. The root of the tree is established as 30, with subsequent nodes placed according to BST properties: nodes in the right subtree are greater than the current node, while those in the left subtree are smaller. The correct insertion order is crucial for maintaining the BST structure, ensuring that each node is positioned accurately based on its value.

PREREQUISITES
  • Understanding of Binary Search Tree (BST) properties
  • Familiarity with node insertion algorithms
  • Basic knowledge of tree data structures
  • Ability to visualize hierarchical data
NEXT STEPS
  • Study the algorithm for inserting nodes into a Binary Search Tree
  • Learn about tree traversal methods (in-order, pre-order, post-order)
  • Explore balancing techniques for Binary Search Trees
  • Investigate the differences between Binary Search Trees and other tree structures like AVL trees
USEFUL FOR

Computer science students, software developers, and anyone interested in data structure optimization and algorithm design will benefit from this discussion.

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: 129
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: 139
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: 115
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