Huffman coding: Difference between revisions

Content added Content deleted
Line 3,210: Line 3,210:
{{trans|Java}}
{{trans|Java}}
This implementation creates an actual tree structure, and then traverses the tree to recover the code.
This implementation creates an actual tree structure, and then traverses the tree to recover the code.
<lang kotlin>import java.util.*
<lang kotlin>abstract class HuffmanTree(var freq: Int) : Comparable<HuffmanTree> {

abstract class HuffmanTree(var freq: Int) : Comparable<HuffmanTree> {
override fun compareTo(other: HuffmanTree) = freq - other.freq
override fun compareTo(other: HuffmanTree) = freq - other.freq
}
}