ãããã³ç¬¦å·åã«ä½¿ããããã³ããªã¼ãRubyã§ä½ã£ã¦ã¿ãã2æ¬ã®ãã¥ã¼ãç¨æãã¦ã2ã¤ã®ãã¼ãããã£ã¤ãããåºãå
¥ãããã®ãç°¡åã¨ããã®ã§ããããæ¹éã§ãæ¬å½ã¯1æ¬ã¯ãã©ã¤ãªãªãã£ã»ãã¥ã¼ã§ãªãã¨ã¨ã³ãã¥ã¼æã«ã½ã¼ãããããã«å¹çãæªãã # Huffman coding # class Node attr_accessor :val, :weight, :left, :right def initialize(val = "", weight = 0) @val, @weight = val, weight end def leaf? !(left and right) end end class HuffmanTree attr_accessor :freq, :que1, :que2, :root def initialize(str) @freq = count_freq(str.
{{#tags}}- {{label}}
{{/tags}}