Knowee
Questions
Features
Study Tools

A binary search tree is generated by inserting following integers: 41, 30, 60, 25, 78, 90, 39, 50The number of nodes in the left subtree and right subtree of the root respectivelyA3, 4B5, 3C3, 5D4, 4

Question

A binary search tree is generated by inserting following integers: 41, 30, 60, 25, 78, 90, 39, 50The number of nodes in the left subtree and right subtree of the root respectivelyA3, 4B5, 3C3, 5D4, 4

🧐 Not the exact question you are looking for?Go ask a question

Solution

The binary search tree is generated by inserting the integers in the following order: 41, 30, 60, 25, 78, 90, 39, 50.

Step 1: The first number 41 becomes the root of the tree.

Step 2: The second number 30 is less than 41, so it becomes the left child of the root.

Step 3: The third number 60 is greater than 41, so it becomes the right child of the root.

Step 4: The fourth number 25 is less than 41 and also less than 30, so it becomes the left child of 30.

Step 5: The fifth number 78 is greater than 41 and also greater than 60, so it becomes the right child of 60.

Step 6: The sixth number 90 is greater than all the previous numbers, so it becomes the right child of 78.

Step 7: The seventh number 39 is less than 41 but greater than 30, so it becomes the right child of 30.

Step 8: The eighth number 50 is greater than 41 but less than 60, so it becomes the left child of 60.

So, the left subtree of the root (41) has the nodes 30, 25, and 39. Therefore, there are 3 nodes in the left subtree.

The right subtree of the root (41) has the nodes 60, 78, 90, and 50. Therefore, there are 4 nodes in the right subtree.

So, the answer is A3, 4.

This problem has been solved

Similar Questions

Construct the Binary Search Tree of 5, 10, 4, 2, 16, 7, 1, 20, 15, 3

Explain the process of inserting nodes into a binary search tree.give the answer for 5 marks

A binary search tree is a binary tree where:Group of answer choicesThe data in the tree is stored in a specific order.It is always a complete binary tree.The left subtree contains values less than the root, and the right subtree contains values greater than the root.Both b and d.

Where is the maximum number in a binary search tree? a) At the root of the tree. b) Anywhere other than root and leaf nodes c) At the leftmost leaf node. d) At the rightmost leaf node

How to insert a new node to Binary Search Tree? a. Insert a new node as the last element of the last level and call heapify() method b. Starting from the root go to the right or left child of each node according to the new node`s key recursively till it finds an empty position c. Place a new node as the root of BST and set a previous root as a right child of a new root d. None of the above e. Starting from the root go to the right or left child of each node according to the new node`s key recursively till it finds a node with the same key

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.