mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James R Bruce <bruce+@andrew.cmu.edu>
To: linux-kernel@vger.kernel.org
Cc: Helge Hafting <helgehaf@idb.hist.no>,
	Manoj Sontakke <manojs@sasken.com>,
	linux-kernel@vger.kernel.org
Subject: Re: quicksort for linked list
Date: Tue, 13 Mar 2001 01:59:53 -0500 (EST)	[thread overview]
Message-ID: <UufQJdRz0001R5nYw7@andrew.cmu.edu> (raw)
In-Reply-To: <y7r7l1xl9tx.fsf@sytry.doc.ic.ac.uk>
In-Reply-To: <200103091152.MAA31645@cave.bitwizard.nl> <y7r7l1xl9tx.fsf@sytry.doc.ic.ac.uk>


Hi again.  The latter half of my email seems to have been forgotten in
the ensuing discussion, so I'll repost.  For a linked list of any
non-floating point data, radix sort is almost impossible to beat; it's
iterative, fast (linear time for fixed size integers, worst case), can
be stopped early for partial sorting, and has a pretty simple
implementation.

I've been using essentially the same radix sort implementation I
posted before to sort 1000 item lists 60 times a second in a numerical
application, and it barely shows up in the total time used when
profiling.  The other sorts I tried did not fare so well.  I would
much rather see this in a kernel modification than any
merge/quick/heap sort implementations I've seen so far for linked
lists.  OTOH, this conversation seems to have wandered out of
kernel-space anyway...

 - Jim Bruce

(Examples at: http://www.cs.cmu.edu/~jbruce/sort.cc)

10-Mar-2001 Re: quicksort for linked list by David Wragg@doc.ic.ac.uk 
> For modern machines, I'm not sure that quicksort on a linked list is
> typically much cheaper than mergesort on a linked list.  The
> majority of the potential cost is likely to be in the pointer
> chasing involved in bringing the lists into cache, and that will be
> the same for both.  Once the list is in cache, how much pointer
> fiddling you do isn't so important.  For lists that don't fit into
> cache, the advantages of mergesort should become even greater if the
> literature on tape and disk sorts applies (though multiway merges
> rather than simple binary merges would be needed to minimize the
> impact of memory latency).
>
> Given this, mergesort might be generally preferable to quicksort for
> linked lists.  But I haven't investigated this idea thoroughly.
> (The trick described above for avoiding an explicit stack also works
> for mergesort.)


  parent reply	other threads:[~2001-03-13  7:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-09  7:38 Manoj Sontakke
2001-03-09  8:36 ` Helge Hafting
2001-03-09 11:52   ` Rogier Wolff
2001-03-09 12:09     ` Thomas Pornin
2001-03-09 18:52     ` Oliver Xymoron
2001-03-10 16:15       ` Jerome Vouillon
2001-03-09 22:29     ` Michal Jaegermann
2001-03-10 18:50       ` Martin Mares
2001-03-10 23:54         ` Michal Jaegermann
2001-03-10 19:09     ` David Wragg
2001-03-12 19:20       ` Jamie Lokier
2001-03-13  6:59     ` James R Bruce [this message]
2001-03-09 18:23   ` Oliver Xymoron
2001-03-09 11:09 ` James R Bruce
2001-03-09 11:50   ` Alan Cox
2001-03-09 18:39     ` Oliver Xymoron
2001-03-09 13:46 ` James Lewis Nance

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=UufQJdRz0001R5nYw7@andrew.cmu.edu \
    --to=bruce+@andrew.cmu.edu \
    --cc=helgehaf@idb.hist.no \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manojs@sasken.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®