Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
193 views
in Technique[技术] by (71.8m points)

c++ - What kind of tree implementation is STL set?

I know that in STL vector represents the implementation of a dynamic array. So does the list represents the implementation of a linked list (doubly linked list). I know that set has an implementation similar to tree . Looking at the algorithm complexity as mentioned most of the inbuilt function in set is of complexity o(1) or o(log n). So is this tree implemented as Balanced Tree or any other kind of tree such as red-black tree and if So Why such a tree structure was chosen ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The standard imposes no restrictions on the implementation (other than the complexity guarantees).

In other words, it's implementation-dependent. Typically, it's a red-black tree (see e.g. /usr/include/c++/x.y.z/bits/stl_tree.h, where x.y.z is your particular GCC version).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...