Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. In third case of deletion in binary search trees when node is to be deleted has both childs, node data is replaced with

 

1. In third case of deletion in binary search trees when node is to be deleted has both childs, node data is replaced with its predecessor or successor. Let's say that we replace it with its successor. For finding successor, we studied the following algorithm SUCCESSOR(1) 1 if RIGHT(2) 2 3 else 4 5 6 7 8 return y null return BSTMIN(RIGHT (2)) y-PARENT(2) while y null and z = RIGHT(y) 2-y y-- PARENT(y) a. Provide a case when lines 4-7 are applicable to find the successor of a node. b. What will this code return when a node has no successor? Dry run this code with such an example. Note that parts a-b shouldn't be answered in context of deletion of nodes from the tree. c. Write down the scenario in tree deletion when statements in lines 4-7 are executed in order to replace the node deleted with its successor. Provide reason within two lines for such answer.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Programming questions

Question

what expenses are deductible on sch L of form 706?

Answered: 1 week ago