[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 346
  • Last Modified:

stl sort

Hi there,

I am interested in finding out the amount of memory that is being used by stl's sort.
I have read the link :http://www.sgi.com/tech/stl/sort.html and there is mention about complexity but nothing about memory .

Could anyone please direct me to the link ?

Thanks,
0
zizi21
Asked:
zizi21
3 Solutions
 
Infinity08Commented:
The memory complexity of the std::sort algorithm is not defined in the standard, so there's no way to be sure what the memory complexity is for a given implementation (apart from reading the implementation's documentation).

However, I'd expect the memory complexity to be O(1) or O(log n).

You'll note that the SGI implementation (cfr the link you posted) mentions that the introsort algorithm is used. The introsort algorithm has an O(log n) memory complexity.
0
 
evilrixSenior Software Engineer (Avast)Commented:
Since the standard STL sort is generally a quick sort the worse case memory usage will be O(logn).

http://en.wikipedia.org/wiki/Quicksort
0
 
theKashyapCommented:
As someone mentioned it's implementation dependent.
Find out what's teh implementation (STL code would anyway be available) and then refer to the table in this page, it has the memory complexity described for most common algorithms.

Or did you mean you want a real number, say in KB?
- For that easiest is to run with a profiler (E.g. Rational Quantify)
- Or you can write some code like this or this depending on your needs.
0
 
zizi21Author Commented:
Thanks for the help..
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now