Generic quicksort library that can be used to sort an array having any data type (int, char *, struct key_value *, etc.).
Amit
amitchoudhary0523@gmail.com
Fri Sep 26 18:07:19 GMT 2025
>
> >> [1]
> https://pubs.opengroup.org/onlinepubs/9799919799/functions/qsort.html
> >
> >
> > This is fine with me. But then why name it qsort(). Why not call it
> sort().
> >
> > Anyways, anyone who sees qsort() will assume that it is quicksort.
> >
> > Anyways, there is no point in debating about the name of the function.
>
> Because that is what the standard requires that the function is named.
>
> Most users will care how it performs in the typical use case, not what
> algorithm is used under the hood.
>
> Collin
>
I don't know about other users but for sorting I would want to know which
algorithm is being used.
So, if both quicksort and mergesort options are there, then I will choose
quicksort because it has no extra memory requirements.
Mergesort will most probably fail if the array has 1 billion single byte
elements because getting 500 MB of memory may fail.
And since linux has optimistic/aggresive memory allocation then it is quite
possible that when mergesort actually uses the whole 500 MB memory then OOM
may come in picture and kill some other program.
Mergesort is actually not good compared to quicksort because of memory
requirements.
----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250926/45c1e4e6/attachment.htm>
More information about the Libc-alpha
mailing list