POV-Ray : Newsgroups : povray.off-topic : Linked lists Server Time
1 Nov 2024 21:19:19 EDT (-0400)
  Linked lists (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: Invisible
Subject: Linked lists
Date: 8 Apr 2011 04:03:40
Message: <4d9ec15c$1@news.povray.org>
Yesterday I was working on a small Haskell library for working with 
mutable double-linked lists. Man, it's been such a long time since I 
worked with this data structure, I'd forgotten how great it is!

OK, the down-side: Sequential access. You can only access lists 
sequentially. Obtaining the Nth element is a linear-time operation, and 
any attempt at parallel processing is fairly doomed from the start.

On the other hand, if you need to process *all* the data in your 
container anyway, being limited to only sequential access might not be 
all that bad. And you still have O(1) access to any node which you 
already happen to have a pointer to.

So there's a big down-side. Now what's the up-side? Well, lists are 
trivially resizeable. (That's an expensive operation for anything 
array-based.) And they support a large number of O(1) operations. 
Joining two lists is O(1). Splitting a list into two lists is O(1). 
Inserting or deleting elements is O(1). Adding or removing entire 
sublists is O(1). Moving a bunch of elements from one spot to another is 
O(1). All these rearrangements that would usually be quite expensive 
become O(1) on lists.

I'm enjoying myself here. Especially the bit where I implemented 
transactional lists, so all these sophisticated list manipulations are 
thread-safe without me having to worry about deadlock. I can even do 
stuff like "move to the next node in the list, or block until one is added".


Post a reply to this message

From: bart
Subject: Re: Linked lists
Date: 8 Apr 2011 08:57:42
Message: <4d9f0646$1@news.povray.org>
On 04/08/2011 09:03 AM, Invisible wrote:
>
> OK, the down-side: Sequential access. You can only access lists
> sequentially. Obtaining the Nth element is a linear-time operation, and
> any attempt at parallel processing is fairly doomed from the start.
>
Have you considered a skip list structure?
(http://en.wikipedia.org/wiki/Skip_list)


Post a reply to this message

From: Invisible
Subject: Re: Linked lists
Date: 8 Apr 2011 09:09:03
Message: <4d9f08ef$1@news.povray.org>
>> OK, the down-side: Sequential access. You can only access lists
>> sequentially. Obtaining the Nth element is a linear-time operation, and
>> any attempt at parallel processing is fairly doomed from the start.
>>
> Have you considered a skip list structure?
> (http://en.wikipedia.org/wiki/Skip_list)

No - mainly because I've never heard of it. ;-)

However, according to Wikipedia, it does everything in logarithmic time. 
Well, so does a tree [assuming you can keep it balanced]. Haskell 
already has a bazillion different tree implementations [although I don't 
recall seeing a mutable one recently].


Post a reply to this message

From: bart
Subject: Re: Linked lists
Date: 8 Apr 2011 10:46:53
Message: <4d9f1fdd$1@news.povray.org>
On 04/08/2011 02:09 PM, Invisible wrote:
> No - mainly because I've never heard of it. ;-)
>
> However, according to Wikipedia, it does everything in logarithmic time.
> Well, so does a tree [assuming you can keep it balanced]. Haskell
> already has a bazillion different tree implementations [although I don't
> recall seeing a mutable one recently].

Skip lists structure is claimed to be so simple,
that it could be easily implemented within an hour
without a textbook  (http://goo.gl/yDqKJ).


Post a reply to this message

From: Darren New
Subject: Re: Linked lists
Date: 8 Apr 2011 13:01:05
Message: <4d9f3f51$1@news.povray.org>
On 4/8/2011 6:09, Invisible wrote:
> However, according to Wikipedia, it does everything in logarithmic time.

It moves forward and back in linear time. It moves far forward in 
logarithmic time if you make it tall enough. It's like an unholy union of 
tree and list that automatically keeps itself balanced. It's worth reading 
about, because it's interesting and easy to understand.

The nice thing is a skip graph, which is as efficient as a skip list except 
you can make it distributed like a DHT.

-- 
Darren New, San Diego CA, USA (PST)
   "Coding without comments is like
    driving without turn signals."


Post a reply to this message

From: nemesis
Subject: Re: Linked lists
Date: 8 Apr 2011 22:45:00
Message: <web.4d9fc71a39d65a313f0adf870@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> Yesterday I was working on a small Haskell library for working with
> mutable double-linked lists. Man, it's been such a long time since I
> worked with this data structure, I'd forgotten how great it is!

then why not using a LISt Processing language? ;)


Post a reply to this message

From: Orchid XP v8
Subject: Re: Linked lists
Date: 9 Apr 2011 04:30:16
Message: <4da01918$1@news.povray.org>
On 09/04/2011 03:40 AM, nemesis wrote:
> Invisible<voi### [at] devnull>  wrote:
>> Yesterday I was working on a small Haskell library for working with
>> mutable double-linked lists. Man, it's been such a long time since I
>> worked with this data structure, I'd forgotten how great it is!
>
> then why not using a LISt Processing language? ;)

Because I prefer working with a system that offers static type 
guarantees? And thread safety? And sane syntax? And...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Invisible
Subject: Re: Linked lists
Date: 12 Apr 2011 06:46:42
Message: <4da42d92$1@news.povray.org>
On 09/04/2011 03:40 AM, nemesis wrote:
> Invisible<voi### [at] devnull>  wrote:
>> Yesterday I was working on a small Haskell library for working with
>> mutable double-linked lists. Man, it's been such a long time since I
>> worked with this data structure, I'd forgotten how great it is!
>
> then why not using a LISt Processing language? ;)

Also, as a mere technicality... Aren't lists in Lisp *single* linked 
rather than *double* linked?


Post a reply to this message

From: Invisible
Subject: Re: Linked lists
Date: 12 Apr 2011 06:50:17
Message: <4da42e69$1@news.povray.org>
> It's worth
> reading about, because it's interesting and easy to understand.

By contrast, I didn't bother reading much further because it appears to 
be very complex and difficult to understand.

> The nice thing is a skip graph, which is as efficient as a skip list
> except you can make it distributed like a DHT.

What's a DHT when it's at home?


Post a reply to this message

From: Darren New
Subject: Re: Linked lists
Date: 12 Apr 2011 11:42:32
Message: <4da472e8@news.povray.org>
On 4/12/2011 3:50, Invisible wrote:
>> It's worth
>> reading about, because it's interesting and easy to understand.
>
> By contrast, I didn't bother reading much further because it appears to be
> very complex and difficult to understand.

Well, come on. Look at the pictures and you can understand what's going on. :-)

>> The nice thing is a skip graph, which is as efficient as a skip list
>> except you can make it distributed like a DHT.
>
> What's a DHT when it's at home?

a Hash Table that's not Distributed?

-- 
Darren New, San Diego CA, USA (PST)
   "Coding without comments is like
    driving without turn signals."


Post a reply to this message

Goto Latest 10 Messages Next 1 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.