In: Computer Science
Data structure
Binary Search Tree: We know, a BST is a binary tree with one special property: All nodes on the left of a node is smaller and all on the right is larger than the node itself.
Given data: 1, 2, 3, 4, 5, 6, 7
Random BST:
BST with minimum height:
BST with maximum height:
*********************
For the second part, drawing a BST after every insertion will be extremely strenous. So instead, I'll try to write it in texts.
2 a
Insert 10
BST:
10
Insert 20
BST:
10
20
Insert 30
BST:
10
20
30
Insert 40
BST:
10
20
30
40
2 b
Insert 30
BST:
30
Insert 20
BST:
30
20
Insert 40
BST:
30
20 40
Insert 10:
BST:
30
20 40
10
2 c
Insert 20
BST:
20
Insert 10
BST:
20
10
Insert 30
BST:
20
10 30
Insert 40
BST:
20
10 30
40
In case of any doubt drop a comment and I'll surely get back to you.
Please give a like if you're satisfied with the answer. Thank you.