Huffman tree


A Huffman tree.
The Huffman tree generated from the frequencies of symbols in "this is an example of a huffman tree".

A Huffman tree is a tree where every path from the root to a leaf represents a prefix-free code for that leaf's corresponding symbol. Symbols are organized in the tree such that those which appear most frequently in the given data have the shortest paths from the root (the shortest encodings). Huffman trees are an application of trees in data compression.

In a system with prefix-free codes, the code for any symbol is never a prefix of another symbol's code. The Huffman code for a symbol is obtained by taking the unique path from the root to that symbol's associated leaf, marking each left with a \(0\), and every right with a \(1.\) For example, in the Huffman tree to the right, the code for \(a\) is \(010.\) You'll find that no other symbol's code in that tree starts with \(010\) because by taking that path, you'll already be at a leaf. To decode \(010\), just follow the path it specifies. The uniqueness of paths in trees maps each code to exactly \(1\) symbol.

Huffman trees give symbols variable-length codes (\(a\) is \(010\), \(t\) is \(0110\), etc.) which tend to require fewer bits to represent than fixed-length codes like in the ASCII or Unicode standards. The space-efficiency of Huffman trees is due to them being tailored to the exact frequencies of the characters in the text they are meant to encode.

Logic & Proofs
IntegerRational numberInequalityReal numberTheoremProofStatementProof by exhaustionUniversal generalizationCounterexampleExistence proofExistential instantiationAxiomLogicTruthPropositionCompound propositionLogical operationLogical equivalenceTautologyContradictionLogic lawPredicateDomainQuantifierArgumentRule of inferenceLogical proofDirect proofProof by contrapositiveIrrational numberProof by contradictionProof by casesSummationDisjunctive normal form
Set Theory
SetElementEmpty setUniversal setSubsetPower setCartesian productStringBinary stringEmpty stringSet operationSet identitySet proof
Functions
FunctionFloor functionCeiling functionInverse function
Algorithms
AlgorithmPseudocodeCommandAsymptotic notationTime complexityAtomic operationBrute-force algorithm
Relations
RelationReflexive relationSymmetric relationTransitive relationRelation compositionEquivalence relationEquivalence class
Number Theory
Integer divisionLinear combinationDivision algorithmModular arithmeticPrime factorizationGreatest common divisorLeast common multiplePrimality testFactoring algorithmEuclid's theoremPrime number theoremEuclidean algorithm
Induction
Proof by inductionFibonacci sequenceProof by strong inductionWell-ordering principleSequenceFactorialRecursive definition
Combinatorics
Rule of productRule of sumBijection rulePermutationCombinationComplement ruleExperimentOutcomeSample spaceEventProbabilityProbability distributionUniform distributionMultisetSixfold wayInclusion-exclusion principlePigeonhole principle
Graph Theory
GraphWalkSubgraphRegular graphComplete graphEmpty graphCycle graphHypercube graphBipartite graphComponentEulerian circuitEulerian trailHamiltonian cycleHamiltonian pathTreeHuffman treeSubstringForestPath graphStarSpanning treeWeighted graphMinimum spanning treeGreedy algorithmPrim's algorithm
Recursion
RecursionRecursive algorithmCorrectness proofDivide-and-conquer algorithmSorting algorithmMerge sort