Question #7
Revisit
What would be the level-order traversal of the BST formed by inserting the following keys in sequence?
41 53 18 72 63 38 71 79 47 54
Answers
Answered by
16
The Level order traversal we get on forming a Binary Search Tree with the given keys is :
Level 1 : 41
Level 2 : 18, 53
Level 3 : 38, 47, 72
Level 4 : 63, 79
Level 5 : 54, 71
NOTE :
Please have a look at the attachment given below to see the Binary Search Tree formed.
Height of the BST = 4
Explanation :
- In Binary Search tree, we should insert the elements in such a way that the left nodes of the root should be smaller than the root, where the right ones should be larger. The same condition is applied to the intermediate subtrees of the BST too.
- First, insert the first node as a root element.
- Then, take an element and check whether it is smaller than the root or the larger one. If if it is smaller, add it to the left, else to the right.
- And the insertion goes on in the same pattern till the end.
- Level-order traversal uses Breadth-First Search technique in which the search starts from root to the leaf nodes.
- In Level order, to print the elements, we should go by levels and print the elements in each level from left to right.
Learn more :
1) Differences between binary search tree and avl tree.
brainly.in/question/11253443
2) Explain binary tree and binary search tree and operation of binary tree.(data structure)
brainly.in/question/1921211
Attachments:
Similar questions