Jump to content

Huffman coding: Difference between revisions

Line 1,438:
(defn init-pq [s]
(let [c (count s)]
(->> s frequencies
(map (fn [[k v]] [k {:sym k :weight (/ v c)}]))
(into (priority-map-keyfn-by :weight <)))))
 
(defn huffman-tree [pq]
Cookies help us deliver our services. By using our services, you agree to our use of cookies.