qsort

Luiz H de Figueiredo lhf at aries5
Sun Nov 19 05:56:58 AEST 1989


In a recent thread about sorting strings, someone suggested that qsort was
not the way to go because quicksort is not very good for nearly ordered files.

My question is:
	Does qsort have to implement quicksort?

My point is that the *name* qsort is historical but qsort can actually be
very smart, eg. switching to insertion for small segments and/or pre-scan the
file (array) to avoid quadratic behaviour for sorted data.
In other words, qsort does not even have to implement quicksort at all!
What is more useful to assume is that qsort is *very* efficient, so that we
don't have to re-invent the wheel every day.

What does the standard say about this?


Luiz Henrique de Figueiredo		internet: lhf at aries5.uwaterloo.ca
Computer Systems Group			bitnet:   lhf at watcsg.bitnet
University of Waterloo
Waterloo, Ontario, Canada  N2L 3G1



More information about the Comp.lang.c mailing list