Re: Non-recursive chop and clone for Binary Search Tree - Solutions
- From: Ben Pfaff <blp@xxxxxxxxxxxxxxx>
- Date: Sat, 24 Nov 2007 13:26:36 -0800
"jehugaleahsa@xxxxxxxxx" <jehugaleahsa@xxxxxxxxx> writes:
On Nov 23, 6:14 pm, Ben Pfaff <b...@xxxxxxxxxxxxxxx> wrote:
"jehugalea...@xxxxxxxxx" <jehugalea...@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
Right . . . it does everything on the way down using a form of stack.
No. No stack is involved. It's a simple iterative loop.
--
Ben Pfaff
http://benpfaff.org
.
- References:
- Non-recursive chop and clone for Binary Search Tree - Solutions
- From: jehugaleahsa@xxxxxxxxx
- Re: Non-recursive chop and clone for Binary Search Tree - Solutions
- From: Ben Pfaff
- Re: Non-recursive chop and clone for Binary Search Tree - Solutions
- From: jehugaleahsa@xxxxxxxxx
- Non-recursive chop and clone for Binary Search Tree - Solutions
- Prev by Date: Re: help
- Next by Date: Re: reading network data
- Previous by thread: Re: Non-recursive chop and clone for Binary Search Tree - Solutions
- Next by thread: Re: Non-recursive chop and clone for Binary Search Tree - Solutions
- Index(es):
Relevant Pages
|
|