diff options
author | millert <> | 2017-05-20 13:09:01 +0000 |
---|---|---|
committer | millert <> | 2017-05-20 13:09:01 +0000 |
commit | 62d15e6c04cafcfafecc360aa1b0f5805601846e (patch) | |
tree | 11e4725e02f5e28ff9f02db615e8e11fb0650743 | |
parent | 78fdfc7b710f4922d56e067d044f7f7087c0872e (diff) | |
download | openbsd-62d15e6c04cafcfafecc360aa1b0f5805601846e.tar.gz openbsd-62d15e6c04cafcfafecc360aa1b0f5805601846e.tar.bz2 openbsd-62d15e6c04cafcfafecc360aa1b0f5805601846e.zip |
Document that qsort falls back to heapsort() if the recursion depth
exceeds 2 lg N and add a reference to the introsort paper.
-rw-r--r-- | src/lib/libc/stdlib/qsort.3 | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/lib/libc/stdlib/qsort.3 b/src/lib/libc/stdlib/qsort.3 index f753777780..29a29f3a4d 100644 --- a/src/lib/libc/stdlib/qsort.3 +++ b/src/lib/libc/stdlib/qsort.3 | |||
@@ -29,9 +29,9 @@ | |||
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
30 | .\" SUCH DAMAGE. | 30 | .\" SUCH DAMAGE. |
31 | .\" | 31 | .\" |
32 | .\" $OpenBSD: qsort.3,v 1.19 2016/03/12 21:31:22 mmcc Exp $ | 32 | .\" $OpenBSD: qsort.3,v 1.20 2017/05/20 13:09:01 millert Exp $ |
33 | .\" | 33 | .\" |
34 | .Dd $Mdocdate: March 12 2016 $ | 34 | .Dd $Mdocdate: May 20 2017 $ |
35 | .Dt QSORT 3 | 35 | .Dt QSORT 3 |
36 | .Os | 36 | .Os |
37 | .Sh NAME | 37 | .Sh NAME |
@@ -111,7 +111,9 @@ Algorithm Q. | |||
111 | .Fn qsort | 111 | .Fn qsort |
112 | takes O N lg N average time. | 112 | takes O N lg N average time. |
113 | This implementation uses median selection to avoid its | 113 | This implementation uses median selection to avoid its |
114 | O N**2 worst-case behavior. | 114 | O N**2 worst-case behavior and will fall back to |
115 | .Fn heapsort | ||
116 | if the recursion depth exceeds 2 lg N. | ||
115 | .Pp | 117 | .Pp |
116 | The | 118 | The |
117 | .Fn heapsort | 119 | .Fn heapsort |
@@ -209,6 +211,14 @@ were unable to allocate memory. | |||
209 | .%P pp. 1249\-1265 | 211 | .%P pp. 1249\-1265 |
210 | .%D November 1993 | 212 | .%D November 1993 |
211 | .Re | 213 | .Re |
214 | .Rs | ||
215 | .%A Musser, D. | ||
216 | .%T "Introspective Sorting and Selection Algorithms" | ||
217 | .%J "Software \- Practice and Experience" | ||
218 | .%V Vol. 27(8) | ||
219 | .%P pp. 983\-993 | ||
220 | .%D August 1997 | ||
221 | .Re | ||
212 | .Sh STANDARDS | 222 | .Sh STANDARDS |
213 | Previous versions of | 223 | Previous versions of |
214 | .Fn qsort | 224 | .Fn qsort |