Re: [Haskell-cafe] Re: can there be (hash-table using) O(n) version of this (I think currently) n log n algo?

2009-12-09 Thread Matt Morrow
Never underestimate teh power of the Int{Set,Map}: {-# LANGUAGE BangPatterns #-} import Data.Set(Set) import Data.IntSet(IntSet) import qualified Data.Set as S import qualified Data.IntSet as IS import Control.Parallel.Strategies(rnf) import Data.Monoid(Monoid(..)) import Data.List findsumsIS ::

Re: [Haskell-cafe] Re: can there be (hash-table using) O(n) version of this (I think currently) n log n algo?

2009-12-08 Thread Jon Harrop
On Sunday 19 July 2009 09:26:14 Heinrich Apfelmus wrote: > Thomas Hartman wrote: > > The code below is, I think, n log n, a few seconds on a million + element > > list. > > > > I wonder if it's possible to get this down to O(N) by using a > > hashtable implemementation, or other better data structu

[Haskell-cafe] Re: can there be (hash-table using) O(n) version of this (I think currently) n log n algo?

2009-07-19 Thread Heinrich Apfelmus
Thomas Hartman wrote: > The code below is, I think, n log n, a few seconds on a million + element > list. > > I wonder if it's possible to get this down to O(N) by using a > hashtable implemementation, or other better data structure. > > -- findsums locates pairs of integers in a list > that add