[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: 5.2 work3 manual
- From: Tony Finch <dot@...>
- Date: Tue, 25 May 2010 13:56:49 +0100
On Tue, 25 May 2010, Javier Guerra Giraldez wrote:
> On Sun, May 23, 2010 at 10:09 AM, Florian Weimer <fw@deneb.enyo.de> wrote:
> >> Your definition requires an O(n) search to evaluate #x, whereas Lua's
> >> definition allows an O(log n) search.
> >
> > Not really, you could use balanced binary trees or Judy trees, which
> > would bring you down to O(log n). On the other hand, I'm sure that
> > the constants would be far worse than the current implementation.
>
> and a reverse linked list could keep it at O(1); but all these assume
> maintaining extra structure and keep it current on every assignment.
I don't see how you can get it to O(1) with something as simple as a list.
The hard part is dealing with splitting and joining contiguous sections of
non-nil array elements, where one assignment can change #t by a large
number. I think the best you can do (except for the constant factors!) is
to have an auxiliary balanced tree containing information about the
contiguous sections, in which case array updates would cost O(log n) where
n is the number of sections.
Tony.
--
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
PORTLAND PLYMOUTH: NORTHEAST, BECOMING CYCLONIC IN PLYMOUTH, 3 OR 4,
INCREASING 5 AT TIMES. SLIGHT OR MODERATE. FOG PATCHES THEN THUNDERY SHOWERS.
MODERATE OR GOOD, OCCASIONALLY VERY POOR.
- References:
- Re: 5.2 work3 manual, Luiz Henrique de Figueiredo
- Re: 5.2 work3 manual, Gavin Wraith
- Re: 5.2 work3 manual, Gavin Wraith
- Re: 5.2 work3 manual, Duncan Cross
- Re: 5.2 work3 manual, Gavin Wraith
- Re: 5.2 work3 manual, Roberto Ierusalimschy
- Re: 5.2 work3 manual, Gavin Wraith
- Re: 5.2 work3 manual, Gavin Wraith
- Re: 5.2 work3 manual, Tony Finch
- Re: 5.2 work3 manual, Florian Weimer
- Re: 5.2 work3 manual, Javier Guerra Giraldez