Re: Non-recursive chop and clone for Binary Search Tree - Solutions



"jehugaleahsa@xxxxxxxxx" <jehugaleahsa@xxxxxxxxx> writes:

At the time, I wasn't in the mood; however, I was recently REQUIRED to
figure it out. The problem: I had an unbalanced tree that needed
destroyed. You can usually get away with a recursive (naive/trivial)
implementation, but you're leaving yourself open for a stack overflow
at some point down the line.

There's no need to use level order for that. I would do it like
this:
http://adtinfo.org/libavl.html/Destroying-a-BST-by-Rotation.html
--
"Mon peu de succès près des femmes est toujours venu de les trop aimer."
--Jean-Jacques Rousseau
.