[Haskell-cafe] Newbie seeking advice regarding data structure for a tricky algorithm

Andrew Wagner wagner.andrew at gmail.com
Tue Apr 24 09:28:30 EDT 2007

Hi Toby,

On 4/24/07, Toby Hutton <toby.hutton at gmail.com> wrote:
> Hi,
> I'm trying to implement a fast kd-tree in Haskell.
> http://en.wikipedia.org/wiki/Kd-tree  It's a binary tree
> representing space partitions.

Trees are pretty easy to implement in haskell, due to their inherent
recursive nature. For example, you can do something like this:

data Tree a = Node a [Tree a]

Then the elements of the list are just the children subtrees of the
current node. This is the approach taken by
for example. I personally think this is easier than trying to define
an actual binary tree. With this approach, the algorithms mentioned in
the wikipedia article above should be relatively straight-forward to

As for the paper cited, and the 'analogous' algorithm, you lost me. I
don't see what the algorithm you gives has to do with the problem, so
I'm quite confused. My suggestion would be to try to translate one of
the algorithms from wikipedia, and use that. If you can't work out how
to do this, feel free to check back with me and/or the list.

Good luck!



More information about the Haskell-Cafe mailing list