Home:ALL Converter>Finding minimum value in std::map

Finding minimum value in std::map

Ask Time:2020-06-10T11:22:34         Author:user3882729

Json Formatter

For a non-selfbalancing binary search tree, finding the minimum in the worst case can take O(N) and average case O(log(N)) to traverse to the corresponding leaf node.

Per CPPreference, the time complexity of the function std::map::begin() is constant. Therefore extending this a little further, de-referencing std::map::begin() which yields the lowest key by default also takes constant time. Can someone explain why this might be the case?

Author:user3882729,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/62295303/finding-minimum-value-in-stdmap
yy