[OT] Rebalancing a Binary Search Tree

P

Philipp

Hello,
(sorry this is not a c++ question, but I didn't know any better NG to
post to)

Is there an easy algorithm to rebalance a binary search tree?
Is free example c++ code available somewhere?

I have found some on the web but all are much to complicated for my
simple application (needs not be fast, can have lots of memory).

I think that writing the BST out to an array by in-order traversal and
reconstructing the tree from there is probably the easiest.
Is there a beautiful recursive algorithm ro reconstruct the tree from an
ordered array so it ends up balanced?

Thanks for any answers
Phil
 
P

Philipp

Philipp said:
Hello,
(sorry this is not a c++ question, but I didn't know any better NG to
post to)

Is there an easy algorithm to rebalance a binary search tree?
Is free example c++ code available somewhere?

I have found some on the web but all are much to complicated for my
simple application (needs not be fast, can have lots of memory).

I think that writing the BST out to an array by in-order traversal and
reconstructing the tree from there is probably the easiest.
Is there a beautiful recursive algorithm ro reconstruct the tree from an
ordered array so it ends up balanced?

OK nevermind. I figured it out myself...
(sorry for the noise)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top