written 3.1 years ago by | modified 3.0 years ago by |
What is Binary Search Tree (BST)? Construct a BST for the following numbers: 47, 55, 23, 17, 39, 11, 50, 9, 19, 74, 33, 28 Show all the steps. Write its preorder traversal
written 3.1 years ago by | modified 3.0 years ago by |
What is Binary Search Tree (BST)? Construct a BST for the following numbers: 47, 55, 23, 17, 39, 11, 50, 9, 19, 74, 33, 28 Show all the steps. Write its preorder traversal
written 3.1 years ago by |
Features of BST:
Binary Search Tree (BST) for the following sequence of numbers-
47, 55, 23, 17, 39, 11, 50, 9, 19, 74, 33, 28
Always consider the first element as the root node. Consider the given elements and insert them in the BST one by one.
This is the required Binary Seach Tree (BST).
In preorder traversal, the root node is visited first, then the left subtree, and then finally the right subtree of BST.
Root Node ---> Left Subtree ---> Right Subtree
Hence, for the above Binary Search Tree Preorder Traversal sequence is like
47, 23, 17, 11, 9, 19, 39, 33, 28, 55, 50, 74