Binary tree search algorithm in C++

B

Bogdan

Hi

Could you recommend a C++ library implementing binary tree search
algorithm ? STL and boost libraries don't seem to provide directly
such a specialized algorithm.

regards
Bogdan
 
A

Alf P. Steinbach /Usenet

* Bogdan, on 19.10.2010 12:15:
Hi

Could you recommend a C++ library implementing binary tree search
algorithm ? STL and boost libraries don't seem to provide directly
such a specialized algorithm.

Check if std::map, std::multimap, std::set or std::multiset fits your needs.

These do binary tree searches for lookup.

At least with ordinary implementations.


Cheers & hth.,

- Alf
 
J

Juha Nieminen

Alf P. Steinbach /Usenet said:
At least with ordinary implementations.

Given that the standard imposes pretty strict requirements for those
data containers, is it even *possible* to use anything but a balanced
binary search tree?
 
A

Alf P. Steinbach /Usenet

* Juha Nieminen, on 19.10.2010 18:57:
Given that the standard imposes pretty strict requirements for those
data containers, is it even *possible* to use anything but a balanced
binary search tree?

Yes, one could use a more general tree. E.g. something like a B-tree (it's a
generalization, see e.g. http://en.wikipedia.org/wiki/B-tree). Or some hybrid
thing, since simple insertions and deletions in an array can be more efficient
for small number of items -- the idea would then be to switch over to tree for
larger number of items.

Cheers,

- Alf
 

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

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top