For the tree in Figure 4.70: a. Which node is the root? b. Which nodes are leaves?
Read moreTextbook Solutions for Data Structures and Algorithm Analysis in Java
Question
Write a program to evaluate empirically the following strategies for removing nodeswith two children:a. Replace with the largest node, X, in TL and recursively remove X.b. Alternately replace with the largest node in TL and the smallest node in TR, andrecursively remove the appropriate node.c. Replace with either the largest node in TL or the smallest node in TR (recursivelyremoving the appropriate node), making the choice randomly.Which strategy seems to give the most balance? Which takes the least CPU time toprocess the entire sequence?
Solution
The first step in solving 4 problem number 15 trying to solve the problem we have to refer to the textbook question: Write a program to evaluate empirically the following strategies for removing nodeswith two children:a. Replace with the largest node, X, in TL and recursively remove X.b. Alternately replace with the largest node in TL and the smallest node in TR, andrecursively remove the appropriate node.c. Replace with either the largest node in TL or the smallest node in TR (recursivelyremoving the appropriate node), making the choice randomly.Which strategy seems to give the most balance? Which takes the least CPU time toprocess the entire sequence?
From the textbook chapter Trees you will find a few key concepts needed to solve this.
Visible to paid subscribers only
Step 3 of 7)Visible to paid subscribers only
full solution