comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Using Red-Black Trees
Date: Tue, 16 Nov 2010 21:10:22 -0800 (PST)
Date: 2010-11-16T21:10:22-08:00	[thread overview]
Message-ID: <df137fe2-722f-48d5-aa66-3d32dc745cb0@j9g2000vbr.googlegroups.com> (raw)
In-Reply-To: ibvfst$pgb$1@news.eternal-september.org

On Nov 16, 6:50 pm, "Alex Mentis" <f...@invalid.invalid> wrote:
> Randy Brukardt wrote:
> > Unless you are a student, worrying about a specific data structure is
> > silly in 99% of the cases.
>
> Some students do use Ada.
>
> > I don't know what data
> > structures this newsreader and browser use, but they're good enough
> > for the application, so why should I care?? Same goes for the
> > standard containers.
>
> Ah, ignorance is bliss!  "It just works."  We should call it iAda and
> sell it to Steve Jobs. :-)
>
> Implementation matters to some people, and it's not my job to decide
> when it should and shouldn't matter to them.  Of course, maybe that
> *is* your job...I don't want to be presumptuous. :-)
>
> Sometimes, when you're not building an airplane, you just want to use a
> data structure you know works and not have to do a lot of performance
> benchmarking.  In this case, the ARM only guarantees O((log n)**2)
> performance for particular operations, but a red-black tree should
> perform significantly better, so awareness of the implementation might
> be nice.
>
> I don't really disagree with your philosphy of "trust the container"
> all that much, though, and I'm not trying to start an argument.  So,
> hopefully the smiley emoticons did their job in conveying that.

I think that in a case like this, the truth is somewhere in between.
Like Randy said, in most cases you should not need to care about the
exact implementation.  However, often one does care that an
implementation works well for certain patterns of operations.  For
example, you might have a container-type package that supports
"insert" and "search" operations; but a user that wants to insert all
the data first, calling the Insert operation on data that's already
sorted, and then do searches, would probably prefer a different
implementation than a user that is going to be using the Insert
operation interspersed with searches throughout the program.

In my view, the OP shouldn't have said "I need a self-balancing binary
search tree" or "I need a red-black tree", but simply saying "I need
something that represents an ordered set of data" isn't always good
enough, either.  Sometimes it is.  But ideally it should be something
like "I need something that represents an ordered map, that is
optimized for arbitrary sequences of insertions, deletions, and
lookups" or whatever the needs are.  (And to *really* dream, an
implementation could provide an operation in a child package to allow
the caller to select from a set of optimization options and then
provide alternate implementations.  No, I'm not volunteering to do the
work :) )

                                 -- Adam



  reply	other threads:[~2010-11-17  5:10 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-13 11:20 Using Red-Black Trees Björn
2010-11-13 12:14 ` Phil Thornley
2010-11-13 13:10 ` Alex Mentis
2010-11-13 13:23   ` Björn
2010-11-13 13:53     ` Alex Mentis
2010-11-13 14:06       ` Björn
2010-11-13 16:31       ` Simon Wright
2010-11-15  8:49   ` Stephane Carrez
2010-11-15 15:32     ` John B. Matthews
2010-11-15 22:46   ` Randy Brukardt
2010-11-16 16:10     ` Gene
2010-11-16 17:17       ` Alex Mentis
2010-11-16 19:51         ` Randy Brukardt
2010-11-16 21:24           ` Colin Paul Gloster
2010-11-17  2:50           ` Alex Mentis
2010-11-17  5:10             ` Adam Beneschan [this message]
2010-11-17 22:59               ` Yannick Duchêne (Hibou57)
2010-11-17 23:15                 ` Vinzent Hoefler
2010-11-17 23:39                   ` Yannick Duchêne (Hibou57)
2010-11-18  0:13                     ` Vinzent Hoefler
2010-11-18  6:27                     ` J-P. Rosen
2010-11-18  7:08                       ` Yannick Duchêne (Hibou57)
2010-11-18 10:47                         ` stefan-lucks
2010-11-18 10:45                           ` Yannick Duchêne (Hibou57)
2010-11-18  9:02                       ` Dmitry A. Kazakov
2010-11-18 12:36                         ` J-P. Rosen
2010-11-18 13:23                           ` Dmitry A. Kazakov
2010-11-17 22:38     ` Yannick Duchêne (Hibou57)
2010-11-13 21:53 ` Jeffrey Carter
2010-11-14  8:20   ` Björn
2010-11-14  8:37     ` Dmitry A. Kazakov
2010-11-13 23:51 ` robin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox