Re: anybody love qsort.c?

1999-08-26 Thread Christopher Seiwald
Apparently, someone does love qsort. Akira Wada wrote: | I think it would be difficult, not impossible, to decide the threshold | (Christopher Seiwald said, "# swaps >= 1024", and Tim Vanderhoek suggested, | "a ratio: #comparisons : # swaps") and to what point of qsort, to make | isort bail back,

Re: anybody love qsort.c?

1999-08-26 Thread Christopher Seiwald
Apparently, someone does love qsort. Akira Wada wrote: | I think it would be difficult, not impossible, to decide the threshold | (Christopher Seiwald said, "# swaps >= 1024", and Tim Vanderhoek suggested, | "a ratio: #comparisons : # swaps") and to what point of qsort, to make | isort bail back

Re: anybody love qsort.c?

1999-08-25 Thread Akira Wada
Christopher Seiwald wrote... >Archie's mod to qsort: > >| >- if (swap_cnt == 0) { /* Switch to insertion sort */ >| >+ if (n <= 32 && swap_cnt == 0) { /* Switch to insertion sort */ > >As Akira Wada points out, this eliminates the benefit of the optimization >in the first place, which i

Re: anybody love qsort.c?

1999-08-25 Thread Akira Wada
Christopher Seiwald wrote... >Archie's mod to qsort: > >| >- if (swap_cnt == 0) { /* Switch to insertion sort */ >| >+ if (n <= 32 && swap_cnt == 0) { /* Switch to insertion sort */ > >As Akira Wada points out, this eliminates the benefit of the optimization >in the first place, which

Re: anybody love qsort.c?

1999-08-23 Thread Tim Vanderhoek
On Mon, Aug 23, 1999 at 12:28:32AM -0700, Christopher Seiwald wrote: > > The alteration that I've tried and tested is to have the isort bail > back to qsort if it does more than N swaps. I put N at 1024, which Perhaps a ratio: #comparisons : # swaps If the ratio gets too high, then bail. --

Re: anybody love qsort.c?

1999-08-23 Thread Tim Vanderhoek
On Mon, Aug 23, 1999 at 12:28:32AM -0700, Christopher Seiwald wrote: > > The alteration that I've tried and tested is to have the isort bail > back to qsort if it does more than N swaps. I put N at 1024, which Perhaps a ratio: #comparisons : # swaps If the ratio gets too high, then bail. --

Re: anybody love qsort.c?

1999-08-23 Thread Ville-Pertti Keinonen
gurne...@efn.org (John-Mark Gurney) writes: > Christopher Seiwald scribbled this message on Aug 18: > > It's a pretty straightforward change to bypass the insertion sort for > > large subsets of the data. If no one has a strong love for qsort, I'll > > educate myself on how to make and contribut

Re: anybody love qsort.c?

1999-08-23 Thread Ville-Pertti Keinonen
[EMAIL PROTECTED] (John-Mark Gurney) writes: > Christopher Seiwald scribbled this message on Aug 18: > > It's a pretty straightforward change to bypass the insertion sort for > > large subsets of the data. If no one has a strong love for qsort, I'll > > educate myself on how to make and contrib

Re: anybody love qsort.c?

1999-08-23 Thread Christopher Seiwald
Archie's mod to qsort: | >- if (swap_cnt == 0) { /* Switch to insertion sort */ | >+ if (n <= 32 && swap_cnt == 0) { /* Switch to insertion sort */ As Akira Wada points out, this eliminates the benefit of the optimization in the first place, which is to let isort take over if the data is

Re: anybody love qsort.c?

1999-08-22 Thread Christopher Seiwald
Archie's mod to qsort: | >- if (swap_cnt == 0) { /* Switch to insertion sort */ | >+ if (n <= 32 && swap_cnt == 0) { /* Switch to insertion sort */ As Akira Wada points out, this eliminates the benefit of the optimization in the first place, which is to let isort take over if the data is

Re: anybody love qsort.c?

1999-08-21 Thread Akira Wada
Following my previous post: I wrote .. >I believe a reversed dataset would be partitioned >into two subpartitions sorted in order at the 1'st pass of >the partitionings. Is this incorrect ? > Sorry, I'd confirmed BSD qsort's partitioning logic does not guarantee that "a reversed dataset would be p

Re: anybody love qsort.c?

1999-08-21 Thread Akira Wada
Following my previous post: I wrote .. >I believe a reversed dataset would be partitioned >into two subpartitions sorted in order at the 1'st pass of >the partitionings. Is this incorrect ? > Sorry, I'd confirmed BSD qsort's partitioning logic does not guarantee that "a reversed dataset would be

Re: anybody love qsort.c?

1999-08-21 Thread Akira Wada
Archie Cobbs wrote... >Christopher Seiwald writes: >> But as I'm proposing a change to a fairly sensitive piece of code, I'd >> like to keep the change as modest as possible. > >How about this? > >Index: qsort.c >=== >RCS fil

Re: anybody love qsort.c?

1999-08-21 Thread Akira Wada
Archie Cobbs wrote... >Christopher Seiwald writes: >> But as I'm proposing a change to a fairly sensitive piece of code, I'd >> like to keep the change as modest as possible. > >How about this? > >Index: qsort.c >=== >RCS fi

Re: anybody love qsort.c?

1999-08-21 Thread Akira Wada
Archie Cobbs wrote... >Christopher Seiwald writes: >> But as I'm proposing a change to a fairly sensitive piece of code, I'd >> like to keep the change as modest as possible. > >How about this? > >Index: qsort.c >=== >RCS fil

Re: anybody love qsort.c?

1999-08-21 Thread Akira Wada
Archie Cobbs wrote... >Christopher Seiwald writes: >> But as I'm proposing a change to a fairly sensitive piece of code, I'd >> like to keep the change as modest as possible. > >How about this? > >Index: qsort.c >=== >RCS fi

Re: anybody love qsort.c?

1999-08-21 Thread Nick Hibma
You can check the change by recompiling a few utils with the change: (find . -name \*.c | xargs grep -l qsort) ./bin/ps/ps.c ./contrib/gcc/*.c ./contrib/top/commands.c ./games/fortune/strfile/strfile.c ./gnu/usr.bin/sort/sort.c ./sbin/fsck/pass2.c The fsck one is a nice one. Just wack your /usr

Re: anybody love qsort.c?

1999-08-21 Thread Nick Hibma
You can check the change by recompiling a few utils with the change: (find . -name \*.c | xargs grep -l qsort) ./bin/ps/ps.c ./contrib/gcc/*.c ./contrib/top/commands.c ./games/fortune/strfile/strfile.c ./gnu/usr.bin/sort/sort.c ./sbin/fsck/pass2.c The fsck one is a nice one. Just wack your /usr

Re: anybody love qsort.c?

1999-08-20 Thread Archie Cobbs
Christopher Seiwald writes: > But as I'm proposing a change to a fairly sensitive piece of code, I'd > like to keep the change as modest as possible. How about this? Index: qsort.c === RCS file: /home/ncvs/src/lib/libc/stdlib/qsort.c

Re: anybody love qsort.c?

1999-08-20 Thread Archie Cobbs
Christopher Seiwald writes: > But as I'm proposing a change to a fairly sensitive piece of code, I'd > like to keep the change as modest as possible. How about this? Index: qsort.c === RCS file: /home/ncvs/src/lib/libc/stdlib/qsort.

Re: anybody love qsort.c?

1999-08-19 Thread Christopher Seiwald
| How about the code following sig. ? | And the other codes and information on: | | http://www.mars.dti.ne.jp/~a-wada/qsortlib.html Unfortunately, I only use about 5% of my brain, and am incapable of convincing myself (or anyone else) of the correctness or efficiency of your qsort algorithm. In

Re: anybody love qsort.c?

1999-08-19 Thread Christopher Seiwald
| How about the code following sig. ? | And the other codes and information on: | | http://www.mars.dti.ne.jp/~a-wada/qsortlib.html Unfortunately, I only use about 5% of my brain, and am incapable of convincing myself (or anyone else) of the correctness or efficiency of your qsort algorithm. I

Re: anybody love qsort.c?

1999-08-19 Thread Akira Wada
Christopher Seiwald writes: > The FreeBSD qsort implementation has a rather nasty degenerate case. > If you have data that partitions exactly about the median pivot, yet > which is unsorted in either partition, you get get treated to an insertion > sort. Example: > > 1 2 3 4 5 6 7 8 9 10 19

Re: anybody love qsort.c?

1999-08-19 Thread Akira Wada
Christopher Seiwald writes: > The FreeBSD qsort implementation has a rather nasty degenerate case. > If you have data that partitions exactly about the median pivot, yet > which is unsorted in either partition, you get get treated to an insertion > sort. Example: > > 1 2 3 4 5 6 7 8 9 10 1

Re: anybody love qsort.c?

1999-08-19 Thread Christopher Seiwald
Answers to sundry comments: | why don't you implement this w/ the 5 element median selection qsort | algorithm? my professor for cis413 talked about this algorithm and | that it really is the fastest qsort algorithm... qsort algorithms are like stock market tips: only good in retrospect. The

Re: anybody love qsort.c?

1999-08-19 Thread Christopher Seiwald
Answers to sundry comments: | why don't you implement this w/ the 5 element median selection qsort | algorithm? my professor for cis413 talked about this algorithm and | that it really is the fastest qsort algorithm... qsort algorithms are like stock market tips: only good in retrospect. The

Re: anybody love qsort.c?

1999-08-19 Thread Archie Cobbs
Narvi writes: > Doesn't the qsort just switch to isort *if* the partition to sort is short > enough? That's exactly Christopher's point. It should do this but it doesn't. The code is complex but from a quick glance it appears that the decision to switch to insertion sort does not depend on the to

Re: anybody love qsort.c?

1999-08-19 Thread Archie Cobbs
Narvi writes: > Doesn't the qsort just switch to isort *if* the partition to sort is short > enough? That's exactly Christopher's point. It should do this but it doesn't. The code is complex but from a quick glance it appears that the decision to switch to insertion sort does not depend on the t

Re: anybody love qsort.c?

1999-08-19 Thread Narvi
Doesn't the qsort just switch to isort *if* the partition to sort is short enough? Got to check it out, but afaik the size at that qsorts switch to isort is usually between 8 and 24, with 16 being most common - both halfs are shorter than 16, so they get isorted. Sander There i

Re: anybody love qsort.c?

1999-08-19 Thread Narvi
Doesn't the qsort just switch to isort *if* the partition to sort is short enough? Got to check it out, but afaik the size at that qsorts switch to isort is usually between 8 and 24, with 16 being most common - both halfs are shorter than 16, so they get isorted. Sander There

Re: anybody love qsort.c?

1999-08-18 Thread John-Mark Gurney
Christopher Seiwald scribbled this message on Aug 18: > It's a pretty straightforward change to bypass the insertion sort for > large subsets of the data. If no one has a strong love for qsort, I'll > educate myself on how to make and contribute this change. why don't you implement this w/ the 5

Re: anybody love qsort.c?

1999-08-18 Thread John-Mark Gurney
Christopher Seiwald scribbled this message on Aug 18: > It's a pretty straightforward change to bypass the insertion sort for > large subsets of the data. If no one has a strong love for qsort, I'll > educate myself on how to make and contribute this change. why don't you implement this w/ the 5

Re: anybody love qsort.c?

1999-08-18 Thread Archie Cobbs
Christopher Seiwald writes: > The FreeBSD qsort implementation has a rather nasty degenerate case. > If you have data that partitions exactly about the median pivot, yet > which is unsorted in either partition, you get get treated to an insertion > sort. Example: > > 1 2 3 4 5 6 7 8 9 10 19

anybody love qsort.c?

1999-08-18 Thread Christopher Seiwald
The FreeBSD qsort implementation has a rather nasty degenerate case. If you have data that partitions exactly about the median pivot, yet which is unsorted in either partition, you get get treated to an insertion sort. Example: 1 2 3 4 5 6 7 8 9 10 19 18 17 16 14 14 13 12 11 qsort picks

Re: anybody love qsort.c?

1999-08-18 Thread Archie Cobbs
Christopher Seiwald writes: > The FreeBSD qsort implementation has a rather nasty degenerate case. > If you have data that partitions exactly about the median pivot, yet > which is unsorted in either partition, you get get treated to an insertion > sort. Example: > > 1 2 3 4 5 6 7 8 9 10 1

anybody love qsort.c?

1999-08-18 Thread Christopher Seiwald
The FreeBSD qsort implementation has a rather nasty degenerate case. If you have data that partitions exactly about the median pivot, yet which is unsorted in either partition, you get get treated to an insertion sort. Example: 1 2 3 4 5 6 7 8 9 10 19 18 17 16 14 14 13 12 11 qsort picks