set representation question
Hal Daume III
hdaume at ISI.EDU
Tue Nov 11 16:45:56 EST 2003
this is somewhat off topic, but i'll add "does anyone have a haskell
implementation of..." to the beginning to make it more on topic :).
anyway there are a lot of smart people here...
i'm looking for a representation for a set of natural numbers. right now,
my representation is sorted array, which works well. *all* i care about
is being able to quickly calculate the size of the intersection of two
sets. these sets are, in general, very sparse, which means that the
intersections tend to be small.
for example, i might have two sets reprsented by the arrays:
{0,1,10,346,398,1039,3289,3853,9811,89231,50913}
{0,3,98,183,398,1038,5319,7642,9811,13893,93123}
and all i need to be able to do is respond with "3" very very quickly.
using sorted arrays, this takes O(n+m) time (where n and m are the sizes
of the arrays).
i'm willing to pay some up front cost for creating a data structure that
could do this more quickly (i.e., in logarithmic time).
is such a thing possible? "does anyone have a haskell implementation of"
such a thing? :P
thanks!
- hal
--
Hal Daume III | hdaume at isi.edu
"Arrest this man, he talks in maths." | www.isi.edu/~hdaume
More information about the Haskell
mailing list