[Haskell-cafe] Huffman Codes in Haskell

Bulat Ziganshin bulat.ziganshin at gmail.com
Wed Jun 23 02:33:25 EDT 2010


Hello ajb,

Wednesday, June 23, 2010, 6:58:30 AM, you wrote:

>      build ((w1,t1):(w2,t2):wts)
>        = build $ insertBy (comparing fst) (w1+w2, Node t1 t2) wts

this algo is O(n^2). to be O(n) you should handle separate lists of
leafs and nodes, adding new nodes to the tail of second list


-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell-Cafe mailing list