Jump to content

Huffman coding: Difference between revisions

m
m (→‎Testing: add whitespace)
Line 3,736:
===By building a tree===
 
This version uses nested <code>Array</code>s to buildsbuild a tree [https://commons.wikimedia.org/wiki/File:HuffmanCodeAlg.png like shown in this diagram], and then recursively traverses the finished tree to accumulate the prefixes.
 
{{works with|rakudo|2015-12-17}}
Line 3,752:
multi walk ([$node1, $node2], $prefix) { walk $node1, $prefix ~ '0';
walk $node2, $prefix ~ '1'; }</lang>
 
===Without building a tree===
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.