public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: fche@redhat.com (Frank Ch. Eigler)
To: systemtap@sources.redhat.com
Subject: Re: array sorting checked in
Date: Sat, 24 Sep 2005 12:29:00 -0000	[thread overview]
Message-ID: <y0my85mhcoc.fsf@tooth.toronto.redhat.com> (raw)
In-Reply-To: <cd09bdd10509232325619a0e90@mail.gmail.com>


jamesd.wi wrote:

> [...]
> am I missing something?

Yes.

> yet you want to allow sorrting an array of unknown size using bubble
> sort? that can be as bad as O(n log n)

Actually, a bubble sort is even worse at O(n**2).  The main sort
function is described as a "merge sort", but I can't quite recognize
it as such in the code.  I assume all this was chosen for ease of
prototyping rather than longevity.

> [...] The programmer can't know in advance the size of the array, if
> he knew that information he wouldn't be running systemtap.

Array sizes are limited - by design we perform no dynamic memory
allocation during a systemtap session run.  If those limits are
exceeded, the user will be told and will be able to retry with a
larger limits.

Regardless, even if the array size is limited, it can still be large
enough that sorting would be a problem.

> if you want to maintain stability and accuracy, you either have to
> limit the size of the array and quite possibilty store it in order,
> which is O(1) operation for each addition.  [...]

That is incorrect.  If you think about it, you'll see that maintaining
a sorted array (i.e., at each insert/delete operation) is just about
as costly as sorting it once at the end.  I have no idea what you mean
by "accuracy" being a factor either way.


- FChE

  reply	other threads:[~2005-09-24 12:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-23  8:36 Martin Hunt
2005-09-23 17:57 ` Frank Ch. Eigler
2005-09-23 19:44   ` Martin Hunt
2005-09-23 22:20     ` Frank Ch. Eigler
2005-09-24  6:25 ` James Dickens
2005-09-24 12:29   ` Frank Ch. Eigler [this message]
2005-09-24 15:29     ` James Dickens
2005-09-25  6:21     ` Martin Hunt

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=y0my85mhcoc.fsf@tooth.toronto.redhat.com \
    --to=fche@redhat.com \
    --cc=systemtap@sources.redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).