c++ - What's the memory complexity of std::sort() and std::sort_heap()? -
c++ - What's the memory complexity of std::sort() and std::sort_heap()? -
as in title - what's memory complexity of std::sort()
, std::sort_heap()
? (the latter requires std::make_heap()
i'd know memory complexity well.)
i've tried searching on these sites: http://www.cplusplus.com/reference/ http://en.cppreference.com/w/ either missed or mention time complexity. memory complexity of said functions specified anywhere (in c++ standard or other document)? or maybe implementation-dependent?
for std::sort()
found reply on cboard, pretty much says:
quality of implementation issue. different implementations utilize memory more other implementations. beyond that, standard allows specializations std::sort
different iterators categories allowing implementation take between few different options long complexity (time) matches requirements. complexity given not time, numbers of comparisons. implementation perform n³ swap operations.
the memory overhead implementations of std::sort
related depth of recursion , number of local variables stored onto stack each level of recursion. hp / microsoft stl implementation of std::sort
uses quicksort until/unless detects recursion level getting deep in case switches heap sort. if size small, such 32 or less, uses insertionsort.
you can see comparing of algorithms, in wikipedia page , estimate memory complexity.
similarly, suspect other 2 algorithms fall same case.
c++ c++11 big-o c++-standard-library space-complexity
Comments
Post a Comment