# typos in qsort.3, heapsort.c

• To: bugs_(_at_)_openbsd_(_dot_)_org
• Subject: typos in qsort.3, heapsort.c
• From: Brian Poole <raj_(_at_)_cerias_(_dot_)_purdue_(_dot_)_edu>
• Date: Sun, 7 Sep 2003 13:36:30 -0500

```Here are a few typos, missed words, etc. 1st one is based off the
context of the man page & looking at the code.

Index: qsort.3
===================================================================
RCS file: /cvs/src/lib/libc/stdlib/qsort.3,v
retrieving revision 1.12
diff -u -r1.12 qsort.3
--- qsort.3	2 Jun 2003 20:18:38 -0000	1.12
+++ qsort.3	7 Sep 2003 18:23:48 -0000
@@ -122,7 +122,7 @@
.Fn heapsort
takes O N lg N worst-case time.
This implementation of
-.Fn qsort
+.Fn heapsort
is implemented without recursive function calls.
.Pp
The function

Index: heapsort.c
===================================================================
RCS file: /cvs/src/lib/libc/stdlib/heapsort.c,v
retrieving revision 1.4
diff -u -r1.4 heapsort.c
--- heapsort.c	2 Jun 2003 20:18:37 -0000	1.4
+++ heapsort.c	7 Sep 2003 18:32:57 -0000
@@ -68,7 +68,7 @@
* Build the list into a heap, where a heap is defined such that for
* the records K1 ... KN, Kj/2 >= Kj for 1 <= j/2 <= j <= N.
*
- * There two cases.  If j == nmemb, select largest of Ki and Kj.  If
+ * There are two cases.  If j == nmemb, select largest of Ki and Kj.  If
* j < nmemb, select largest of Ki, Kj and Kj+1.
*/
#define CREATE(initval, nmemb, par_i, child_i, par, child, size, count, tmp) { \
@@ -90,12 +90,12 @@
* Select the top of the heap and 'heapify'.  Since by far the most expensive
* action is the call to the compar function, a considerable optimization
* in the average case can be achieved due to the fact that k, the displaced
- * elememt, is ususally quite small, so it would be preferable to first
+ * element, is usually quite small, so it would be preferable to first
* heapify, always maintaining the invariant that the larger child is copied
* over its parent's record.
*
* Then, starting from the *bottom* of the heap, finding k's correct place,
- * again maintianing the invariant.  As a result of the invariant no element
+ * again maintaining the invariant.  As a result of the invariant no element
* is 'lost' when k is assigned its correct place in the heap.
*
* The time savings from this optimization are on the order of 15-20% for the

```