Archived

This topic is now archived and is closed to further replies.

Binary/n-ary trees

This topic is 5917 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Are there any system function or standarized function that let me make a binary/n-ary tree and keep it balanced? If there are someone, where could I find it?

Share this post


Link to post
Share on other sites
Hi.

std::set and std::map
are associative containers, which must guarantee a maximum lookup time of O(lg n).

Now, the only way to ensure that is to use some kind of search tree.

So for what people say, most map implementations are red-black trees... red black trees is binary trees which also must satisfy the 4 Red-black properties all the time.
When the properties are satisfied, the tree will stay balanced.

So that was a bit OT, but what you need is set & map

Share this post


Link to post
Share on other sites