i have a bst tree
and i need to build a function which removes the root and rearanges the remaining tree
so it will remain bst.
??
i cant see a general way of solving it.
for
i just make the right one to be the new root and point its left to 3Code:2 / \ 1 3
but it doest work for this treeCode:1 \ 3
and the 5 should be the next rootCode:6 / \ 4 7 \ \ 5 8
and my method doesnt work here
??
what is the correct algorithm?