M
Max
Hi guys, did some searching on the topic, but can't find much more then
just basic info on binary trees. I need to write a binary tree
implementation so that it is always complete. In other words operations
such as add and delete will not cause the completeness to break.
Re-adding all of the elements to a brand new tree and wiping out the old
one is not an option, so any sorting that I do must be in place.
Does anyone know of a good algorithm for this problem? If you have some
code examples that would be nice, but even just the concept will do. Sat
for a while with paper and pencil and can't quiet figure it out
Recursion would probably be best for this, but every time I write
something that I think will work, there's always some special case where
it doesn't. Anyway, if there is a good sorting routine that I can simply
run on the entire tree to make it complete, please let me know.
Otherwise, I need to know specifics for adding and deleting. In either
case, efficiency is important, so that's why I can't do anything like
copying the data to another location and then messing with it there.
Everything has to be done within the original tree.
Thanks for any advice.
just basic info on binary trees. I need to write a binary tree
implementation so that it is always complete. In other words operations
such as add and delete will not cause the completeness to break.
Re-adding all of the elements to a brand new tree and wiping out the old
one is not an option, so any sorting that I do must be in place.
Does anyone know of a good algorithm for this problem? If you have some
code examples that would be nice, but even just the concept will do. Sat
for a while with paper and pencil and can't quiet figure it out
Recursion would probably be best for this, but every time I write
something that I think will work, there's always some special case where
it doesn't. Anyway, if there is a good sorting routine that I can simply
run on the entire tree to make it complete, please let me know.
Otherwise, I need to know specifics for adding and deleting. In either
case, efficiency is important, so that's why I can't do anything like
copying the data to another location and then messing with it there.
Everything has to be done within the original tree.
Thanks for any advice.