Question
c++ (explain

Question 26 3 pts For the next three questions, consider the following BST: 21 27 We insert node 20. Where does it go? (answe
Question 27 3 pts Now we delete node 34. After the delete, what node is to the right of node 29? HTML Editor В І од - IX E 11
Question 28 3 pts Now we delete node 15. After the delete, what node is to the left of node 23? What node is to this node ri
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question no 26)

Answer) Node 20 will be inserted to the right of node 19.

23 15 29 10 18 27 34 4 35 11 19 (20)

Explanation:- One of the basic properties of BST(binary search tree) is that left child must be smaller than the parent child and right child must be greater than parent child.

Let start from the root node.

Node 23 is greater than node 20 ,therefore node 20 should be placed to the left sub tree of node 23

Node 15 is smaller than node 20 ,therefore node 20 should be placed to the right sub tree of node 15

Node 18 is smaller than node 20 ,therefore node 20 should be placed to the right sub tree of node 18

Node 19 is smaller than node 20 ,therefore node 20 should be placed to the right sub tree of node 19

Question 27)

Answer) Node 35 will on the right of the node 29.

23 15 29 10 8 27 35 4 11 19 20

Explanation)

Since node 34 has no any left child ,therefore we need not be bothered about the left sub tree.

We simply replace node 34 with its right sub child which is node 35.Since node 35 is the right child of node 34 ,it will be greater than node 34 as well as node 29.

Thus BST property also get satisfied.

Question 28)

Answer) Node 18 will be on the left of node 23. Node 19 will be on the right of the node 18.

23 18 29 10 19 27 135 4 TT 20.

Explanation)

Whenever we have to delete a non-leaf node from a binary search tree we can do one of the following two things:-

  1. Delete the required node and replace it with that node present in the right sub-tree which is minimum.In our case the minimum node in the right subtree is 18.
  2. Or we can delete the given node and replace it with the maximum valued node present in the left sub-tree. In our case such node is 11.

Here we are using rule 1 to delete the node.

Please note_- If we use rule 2 ,our answer will be different but both the answers are absolutely correct.

If we use rule 2) our answer will be- Node 11 will be on the left of node 23 .Node 18 will be on the right of node 11.

Add a comment
Know the answer?
Add Answer to:
c++ (explain Question 26 3 pts For the next three questions, consider the following BST: 21...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT