STL and Balanced Trees???

D

Dave

Peter Tkacz said:
Are there any data types within STL that implement a balanced tree?

Peter

Well, the performance requirements imposed on maps, multimaps, sets and
multisets cause them to be implemented as balanced trees.
 
G

Gianni Mariani

Peter said:
Are there any data types within STL that implement a balanced tree?

There is no requirement to implement a certain algorithm but STL
templates that might do somthing similar are std::map<...> or
std::multimap<...> .
 
D

Dave

Gianni Mariani said:
There is no requirement to implement a certain algorithm but STL
templates that might do somthing similar are std::map<...> or
std::multimap<...> .

True, but can anyone think of any known data structures other than balanced
binary trees that would meet the logarithmic time complexity requirements
imposed by the Standard? I'm really seriously asking because, as far as I
know, there are none, but I don't know that I am right on that...
 
J

Jerry Coffin

[ ... ]
Well, the performance requirements imposed on maps, multimaps, sets and
multisets cause them to be implemented as balanced trees.

More or less, partly depending on how tightly you define "tree" -- just
for example, you might be able to do the job with a heap, but it's open
to argument that a heap really IS a tree, just represented differently
than usual.
 
D

Dave

Dave said:
True, but can anyone think of any known data structures other than balanced
binary trees that would meet the logarithmic time complexity requirements
imposed by the Standard? I'm really seriously asking because, as far as I
know, there are none, but I don't know that I am right on that...

In looking around a bit on this, it appears that skip lists might also be a
data structure that could be used to implement the STL associative
containers and meet the logarithmic time complexity requirements.
 
J

Jerry Coffin

[ ... ]
In looking around a bit on this, it appears that skip lists might also be a
data structure that could be used to implement the STL associative
containers and meet the logarithmic time complexity requirements.

IIRC, a skip list provides excellent _expected_ complexity, but at least
the usual ones don't meet the requirements for worst-case complexity.
 

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

Similar Threads

bench: binary trees 10
Trees 7
Balanced binary tree implementation 1
Empty binary trees 7
Binary search trees (AVL trees) 34
Trying to determing if n-ary tree is balanced. 1
Sorting an STL map 1
B-trees 12

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top