36.3k views
5 votes
how the result of inserting 30, 10, 40, 60, 90, 20, 50, 70 into an initially empty binary search tree. b) Is the above tree a full binary tree? Why? Why not? c) Draw the subtree

User MohamedEzz
by
8.9k points

1 Answer

3 votes

Final answer:

To insert the given values into a binary search tree, start with the root, compare each value, and follow the left or right child based on their values. The above tree is not a full binary tree because some nodes have only one child. A subtree is a smaller portion of a binary search tree, and it can be represented with a root and its children.

Step-by-step explanation:

  1. To insert the given values into an initially empty binary search tree, you start by inserting the first value, 30, as the root of the tree. Then, you compare the next value, in this case 10, with the root. Since 10 is less than 30, it becomes the left child of the root. The process continues for the remaining values, following the left or right child of each node based on their values.
  2. The above tree is not a full binary tree. A full binary tree is a binary tree in which every node has either 0 or 2 children. In this case, the nodes with values 50, 70, and 90 have only one child, making it incomplete.
  3. There is no specific subtree mentioned in the question, so I can't draw a specific subtree. However, I can provide a general example of how a subtree would look. Let's say we have a binary search tree with values 30, 10, and 40. The subtree with 10 as the root would have the left child as null and the right child as null.
User Maxbester
by
8.5k points