Why is the complexity of the C++ STL map container O(log(n))?

前端 未结 2 890
一整个雨季
一整个雨季 2021-02-20 17:35

For C++ STL containers such as vector and list, the complexity of finding elements and inserting or removing them is self-explanatory. However, for the

2条回答
  •  广开言路
    2021-02-20 18:02

    As slavik262 points, maps are usually implemented with red-black-trees, which are self-balanced. Check the complexity of a red-black-tree for example in the wikipedia I don't know any implementation of a map with a binary tree; if Mark Ransom knows one, I'd be pleased to know which one.

提交回复
热议问题