228k views
5 votes
A. Place the numbers 10, 16, 1, 4, 5, 17, 12, 21, 2, 6, 8 in the order in which they appear in a binary search tree.

b. During the process of constructing the binary search tree, when you place 17 and 6, please write down the numbers that you need to compare with(please write the number in order i.e., the first number in your answer is the first number you need to compare with).

User Fmjrey
by
4.3k points

1 Answer

1 vote

Answer:

Explanation:

The objective of the question (a) is to place the given numbers 10, 16, 1, 4, 5, 17, 12, 21, 2, 6, 8 in the order in which they appear in a binary search tree.

So; from the attached file below ; we will see a diagram representation the above computation in a binary tree diagram.

However, during the process of constructing the binary search tree ; when i place 17 and 6; the number that i compare with are explained as follows:

Let take them one after the other;

SO for 17; we need to compare 17 with 10 first; then move towards the right to compare it with 16.

So ; the answer is 10,16 in that order.

For 6 ;

We first compare it with 10; go to the left and compare it with 1; then we follow the right path and again compare it with 4; then to the right again by comparing it with 5

So; the answer is 10,1,4,5 in that order.

A. Place the numbers 10, 16, 1, 4, 5, 17, 12, 21, 2, 6, 8 in the order in which they-example-1
User Andrewkslv
by
3.9k points