huffman

package
v0.14.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2023 License: GPL-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package huffman implements an n-ary Huffman coding algorithm to generate prefix-free labels for a set of items.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Label

func Label(alphabetSize int, freqs []int) (labels [][]int)

Label generates unique prefix-free labels for a set of items given their frequencies. Prefix-free labels guarantee that none of the generated labels is a prefix for another.

For each item i, freqs[i] specifies its frequency. Items with higher frequencies will get shorter labels.

Labels are generated using an alphabet of the provided size. For each item i, labels[i] is a list of indexes in the alphabet that comprise that item's label. For example, given a binary alphabet {a b}, the label {0 1 0} means "aba".

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL