Question: / / remove all nodes that have only one child by promoting that child / / repeat this recursively as you go up , so

// remove all nodes that have only one child by "promoting" that child
// repeat this recursively as you go up, so the final result should have no nodes with only one child
// if you start with "41", the tree is unchanged.
// if you start with "412161", the tree is unchanged.
// if you start with the BST "4121111", then the result is the tree "1"
// if you start with the BST "41216111", then the result is the tree "411161"
// Hint: This requires that you check for "singleness" after the recursive calls

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!