Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Which one is faster, sort() or qsort()?

$
0
0

People who code in C use the built-in QSORT, while C++ users prefer the SORT function. Looking through the documentation, I see that both have an average time complexity of nlog(n). But in GeekForGeeks it says experimentally sort() was faster than qsort().

I was wondering why and how sort() is faster than qsort(), because its conventional that the same algorithm written in C would take up less memory and less time as well than the code in C++. And as far as I know both of these functions follow the same sorting algorithm. So isn't qsort() supposed to take less time than sort()?

Is there any special reason/fact about these sorting function that makes C++'s sort() faster than C's qsort()?


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>