Runtime Notes

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Maps are the container in STL which is used to store the elements in the form of

key-value pair. Internally, the elements in a map are always sorted by its key.
Maps are mainly implemented as binary search trees.

Time Complexity for Searching element :


Time complexity for searching elements in std::map is O(log n). Even in worst case
it will be O(log n) because elements are stored internally as Balanced Binary
Search tree (BST) whereas, in std::unordered_map best case time complexity for
searching is O(1).

You might also like