2
Well, you have to define which methodology to adopt. You can choose the node on the left, 30
, as the new knot that will stand in place of the 40
and then in this case you will have to fetch the right most knot of the knot 30
, to allocate the node that was to the right of the 40
, the 44
. Or you can also choose the 44
as the knot that will stand in place of the 40
, and in this case you will have to look for the leftmost node of the 44
to allocate what was left of the 40
, in case the 30
. Anyway it depends on your methodology, and this way will not unbalance your tree. It would not be feasible for you to try to reorganize it so as to put the 41
instead of the node removed, this is because it would be too laborious to ensure that the tree would not be unbalanced.
So based on what he asked in the statement: "For what if you continue to have a binary search tree configuration, after removing the nodes shown below, what will be the new tree configuration? Redesign." Could I put in place the 40, the same number 41 I did? He might consider?
– André
You couldn’t, you have to consider that you don’t know what the values of each node are, because it doesn’t follow a numerical order, and you only know that smaller is left and larger is right. Then, you can only define which child node will be in place, whether the left or right. The tree will continue to be a binary search tree in either of the two options.
– Leonardo Rodrigues