{"id":1308,"date":"2026-08-30T21:19:40","date_gmt":"2026-08-30T21:19:40","guid":{"rendered":"https:\/\/ffritze.de\/?p=1308"},"modified":"2026-09-04T08:33:42","modified_gmt":"2026-09-04T08:33:42","slug":"daten-komprimieren-mit-koepfchen-teil-1-der-huffman-algorithmus-einfach-erklaert","status":"publish","type":"post","link":"https:\/\/ffritze.de\/en\/daten-komprimieren-mit-koepfchen-teil-1-der-huffman-algorithmus-einfach-erklaert\/","title":{"rendered":"Compressing Data with Smarts (Part 1) \u2013 The Huffman Algorithm Explained Simply"},"content":{"rendered":"<p class=\"wp-block-paragraph translation-block\">Conventional computer codes give each letter the same storage space - the common '<strong>E'<\/strong> consumes as much as the rare '<strong>K'<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">The <strong>Huffman algorithm<\/strong> chooses a smarter way: frequent characters get very short codes, rare a little longer. Thus, the amount of data shrinks without any loss of information.<\/p>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">How to create an elegant <strong>Huffman tree<\/strong> from character frequencies step by step, let's look directly at the example word: <strong>KAFFEPAUSE<\/strong>.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">The classic approach: The block code (fixed length code)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">With the traditional <strong>block code<\/strong>, each character is assigned a binary code of equal length. The creation can be displayed wonderfully as a uniform decision tree:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li class=\"translation-block\"><strong>count characters:<\/strong> The word <strong>COFFEE BREAK<\/strong> consists of 11 letters, but uses only <strong>7 different characters<\/strong> (<code>K<\/code>, <code>A<\/code>, <code>F<\/code>, <code>E<\/code>, <code>P<\/code>, <code>U<\/code>, <code>S<\/code>).<\/li>\n\n\n\n<li class=\"translation-block\"><strong>Set Bits:<\/strong> To clearly distinguish 7 different characters, we need a 3-bit code (2^3 = 8 combinations). In the graph, this corresponds to a tree with exactly 3 levels.<\/li>\n\n\n\n<li class=\"translation-block\"><strong>Assign Paths:<\/strong> Each branch to the left stands for a <code>0<\/code>, to the right for a <code>1<\/code>. Each letter is at the end of an exactly 3 step long path.<\/li>\n<\/ol>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6aac12c7e1e1e&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6aac12c7e1e1e\" class=\"wp-block-image size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"623\" height=\"358\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Baum_Blockcode.png\" alt=\"\" class=\"wp-image-1317\" srcset=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Baum_Blockcode.png 623w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Baum_Blockcode-300x172.png 300w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Baum_Blockcode-18x10.png 18w\" sizes=\"auto, (max-width: 623px) 100vw, 623px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Code table (block code)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Since the tree is exactly 3 levels deep, each character receives a 3-bit code:<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6aac12c7e2fb3&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6aac12c7e2fb3\" class=\"wp-block-image size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"484\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Tabelle_Blockcode-1024x484.png\" alt=\"\" class=\"wp-image-1319\" srcset=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Tabelle_Blockcode-1024x484.png 1024w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Tabelle_Blockcode-300x142.png 300w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Tabelle_Blockcode-768x363.png 768w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Tabelle_Blockcode-18x9.png 18w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Tabelle_Blockcode.png 1206w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">The coded text for KAFFEEPAUSE<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Translated letter by letter:<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6aac12c7e3eae&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6aac12c7e3eae\" class=\"wp-block-image size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"115\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Blockcode_Kaffeepause-1024x115.png\" alt=\"\" class=\"wp-image-1320\" srcset=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Blockcode_Kaffeepause-1024x115.png 1024w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Blockcode_Kaffeepause-300x34.png 300w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Blockcode_Kaffeepause-768x87.png 768w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Blockcode_Kaffeepause-18x2.png 18w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Blockcode_Kaffeepause.png 1206w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Total binary code:<\/strong><br><code>000001010010011011100001101110011<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph translation-block\"><strong>Length:<\/strong> 11 letters \u22c5 3 bits = <strong>33 bits<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The problem with this:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">Although the <strong>E<\/strong> occurs three times and <strong>K<\/strong> only once, both consume exactly <strong>3 bits<\/strong>. In addition, the eighth combination (the empty circle at the bottom right) remains completely unused.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Some codes may be shorter: The flex code<\/h2>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">In the block code, all characters have three digits. Although this is clear, it is not absolutely necessary: As soon as the path <code>11<\/code> is reached, we already know that only the character 'S' can be meant. The additional branching would therefore be superfluous.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-87724155 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"wp-block-paragraph translation-block\">Therefore, the 'S' in the code tree can move one plane upwards and receives the shorter code <code>11<\/code>. The remaining characters retain their three-digit codes. This creates a <strong>Flexcode<\/strong>: The code words may be of different lengths, but remain unambiguously decipherable, unless there is a letter further down in the tree than another.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6aac12c7e6202&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6aac12c7e6202\" class=\"wp-block-image size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"623\" height=\"358\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Baum_Flexcode.png\" alt=\"Codebaum f\u00fcr Kaffeepause Flexcode\" class=\"wp-image-1322\" srcset=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Baum_Flexcode.png 623w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Baum_Flexcode-300x172.png 300w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Baum_Flexcode-18x10.png 18w\" sizes=\"auto, (max-width: 623px) 100vw, 623px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-baaca9a6 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6aac12c7e78b4&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6aac12c7e78b4\" class=\"wp-block-image size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"430\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Tabelle_Flexcode-1024x430.png\" alt=\"\" class=\"wp-image-1324\" srcset=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Tabelle_Flexcode-1024x430.png 1024w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Tabelle_Flexcode-300x126.png 300w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Tabelle_Flexcode-768x322.png 768w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Tabelle_Flexcode-18x8.png 18w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Tabelle_Flexcode.png 1206w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:60%\">\n<p class=\"wp-block-paragraph translation-block\">For <strong>KAFFEEPAUSE<\/strong> this results in:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>00000101001001101110000110111011<\/code><\/p>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">The flex code now requires <strong>32 bits<\/strong> instead of 33 bits for the block code. This is only a small difference - but the principle is crucial: not every character has to be given the same amount of space.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why do we need the Huffman algorithm?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">We have already seen with the flex code: codes may be of different lengths. In order to save even more storage space, it would make sense in our example to move the frequently occurring '<strong>E'<\/strong> further up in the tree. Finally, it appears three times in the word, while about '<strong>K'<\/strong>, '<strong>P'<\/strong>, '<strong>U'<\/strong> and <strong>\u201aS<\/strong>\u201a only occur once each.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-87724155 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"wp-block-paragraph\">With only seven characters, you can still consider which arrangement could be particularly favorable. However, with longer texts with many different characters, this quickly becomes confusing. There are then a lot of possible code trees - trying out all variants and comparing them with each other would take far too long.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6aac12c7e93a7&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6aac12c7e93a7\" class=\"wp-block-image size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Huffman_Tafel.png\" alt=\"\" class=\"wp-image-1328\" srcset=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Huffman_Tafel.png 1024w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Huffman_Tafel-300x300.png 300w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Huffman_Tafel-150x150.png 150w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Huffman_Tafel-768x768.png 768w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/Huffman_Tafel-12x12.png 12w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">This is exactly where the <strong>Huffman algorithm<\/strong> helps: It systematically creates a space-saving, clearly readable code tree from the frequencies of the characters. Frequent characters end up as high as possible in the tree and receive short codes; rare characters get longer codes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Frequency analysis<\/h3>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">For the word '<strong>KAFFEEPAUSE'<\/strong>, it is first determined how often each letter occurs: '<strong>E' <\/strong>appears three times, '<strong>A'<\/strong> and '<strong>F'<\/strong> twice each, '<strong>K<\/strong>', '<strong>P'<\/strong>, '<strong>U'<\/strong> and '<strong>S'<\/strong> once each. These frequencies form the basis for the Huffman tree.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Explanation of the procedure<\/h3>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-87724155 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:60%\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6aac12c7ea70d&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6aac12c7ea70d\" class=\"wp-block-image size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"599\" height=\"140\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_1-1-edited.png\" alt=\"\" class=\"wp-image-1340\" srcset=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_1-1-edited.png 599w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_1-1-edited-300x70.png 300w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_1-1-edited-18x4.png 18w\" sizes=\"auto, (max-width: 599px) 100vw, 599px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"wp-block-paragraph\">First, the knots are arranged according to their frequency or weight.<\/p>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-87724155 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"wp-block-paragraph translation-block\">In the next step, the two nodes with the lowest frequencies are always selected and connected to a new node. The frequencies of the two nodes are added. First, for example, <strong>K<\/strong> and <strong>P<\/strong> are combined:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1+1=2<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6aac12c7eba94&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6aac12c7eba94\" class=\"wp-block-image size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"614\" height=\"432\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_2-1.png\" alt=\"\" class=\"wp-image-1331\" srcset=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_2-1.png 614w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_2-1-300x211.png 300w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_2-1-18x12.png 18w\" sizes=\"auto, (max-width: 614px) 100vw, 614px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Thus, a new node with the frequency 2 arises from the two individual nodes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">Subsequently, the two remaining characters are connected with the frequency 1, i.e. <strong>U<\/strong> and <strong>S<\/strong>:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1+1=2<\/p>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">Now there are no single nodes with the frequency 1. What remains are four nodes with the frequency 2 \u2013 the subtrees <strong>KP<\/strong>, <strong>US<\/strong> and the individual characters <strong>A<\/strong> and <strong>F<\/strong> \u2013 and the node <strong>E<\/strong> with the frequency 3.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-87724155 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6aac12c7ece26&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6aac12c7ece26\" class=\"wp-block-image size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"614\" height=\"432\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_3.png\" alt=\"\" class=\"wp-image-1332\" srcset=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_3.png 614w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_3-300x211.png 300w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_3-18x12.png 18w\" sizes=\"auto, (max-width: 614px) 100vw, 614px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"wp-block-paragraph translation-block\">Now the two smallest nodes are selected again. The subtrees <strong>KP<\/strong> and <strong>US<\/strong> are connected:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2+2=4<\/p>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">This creates a larger subtree with the frequency of 4. After that, <strong>A<\/strong> and <strong>F<\/strong> are combined:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2+2=4<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-87724155 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"wp-block-paragraph translation-block\">The frequencies 3, 4 and 4 are now available. The two smallest nodes are <strong>E<\/strong> with 3 and one of the two 4 nodes. In the construction shown, <strong>E<\/strong> and the subtree <strong>AF<\/strong> are connected:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3+4=7<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6aac12c7ee659&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6aac12c7ee659\" class=\"wp-block-image size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"614\" height=\"432\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_4.png\" alt=\"\" class=\"wp-image-1333\" srcset=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_4.png 614w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_4-300x211.png 300w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_4-18x12.png 18w\" sizes=\"auto, (max-width: 614px) 100vw, 614px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-87724155 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Finally, the two remaining subtrees are merged with the frequencies 4 and 7:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">4+7=11<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6aac12c7ef8e1&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6aac12c7ef8e1\" class=\"wp-block-image size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"614\" height=\"432\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_5.png\" alt=\"\" class=\"wp-image-1334\" srcset=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_5.png 614w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_5-300x211.png 300w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_5-18x12.png 18w\" sizes=\"auto, (max-width: 614px) 100vw, 614px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">This means that the Huffman tree is complete. The number <strong>11<\/strong> at the root corresponds to the total number of all characters in the word.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How the codes are created<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Subsequently, each edge of the tree is assigned a binary digit, for example the 0 on the left and the 1 on the right. The code of a character results from the path from the root to its leaf.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-baaca9a6 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:40%\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6aac12c7f0bbd&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6aac12c7f0bbd\" class=\"wp-block-image size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"982\" height=\"724\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/weg_code-edited-1.jpg\" alt=\"\" class=\"wp-image-1337\" srcset=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/weg_code-edited-1.jpg 982w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/weg_code-edited-1-300x221.jpg 300w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/weg_code-edited-1-768x566.jpg 768w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/weg_code-edited-1-16x12.jpg 16w\" sizes=\"auto, (max-width: 982px) 100vw, 982px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"wp-block-paragraph translation-block\">Frequent characters are as high as possible in the tree and receive short codes. Rare characters are further down and receive longer codes. For the example shown, this means that <strong>E<\/strong> with the frequency 3 receives a shorter code than the only once occurring characters <strong>K<\/strong>, <strong>P<\/strong>, <strong>U<\/strong> and <strong>S<\/strong>.<\/p>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">At equal frequencies, there are several equivalent possibilities for which nodes are connected to each other. Therefore, different Huffman trees can arise. It is crucial that in each step the two nodes are combined with the smallest frequencies.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Code board for \"KAFFEEPAUSE\"<\/h3>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">The codes are read from the Huffman tree: <strong>The path from the root to a character corresponds to its code.<\/strong> Each edge is labeled with a <strong>0<\/strong> or <strong>1<\/strong>.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-87724155 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"wp-block-paragraph translation-block\">Example of <strong>E<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-math translation-block\"><math display=\"block\"><semantics><mrow><mtext>Root<\/mtext><mo stretchy=\"false\">\u2192<\/mo><mn>7<\/mn><mo stretchy=\"false\">\u2192<\/mo><mi>E<\/mi><mo><\/mo><mn>11<\/mn><\/mn><\/mrow><annotation encoding=\"application\/x-tex\">\\text{root} \\rightarrow 7 \\rightarrow E = \\mathbf{11}<\/annotation><\/semantics><\/math><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">The codes of the individual characters may look different depending on the inscription of the branches. <\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6aac12c7f2392&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6aac12c7f2392\" class=\"wp-block-image size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1196\" height=\"498\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_table.png\" alt=\"\" class=\"wp-image-1341\" srcset=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_table.png 1196w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_table-300x125.png 300w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_table-1024x426.png 1024w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_table-768x320.png 768w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_table-18x7.png 18w\" sizes=\"auto, (max-width: 1196px) 100vw, 1196px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">It is important that each path is unambiguous and that frequent characters receive as short codes as possible.<\/p>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">With code board, the word <strong>KAFFEPAUSE<\/strong> is encoded as follows:<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6aac12c7f33c9&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6aac12c7f33c9\" class=\"wp-block-image size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"111\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_codiert-1024x111.png\" alt=\"\" class=\"wp-image-1342\" srcset=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_codiert-1024x111.png 1024w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_codiert-300x33.png 300w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_codiert-768x83.png 768w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_codiert-18x2.png 18w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_codiert.png 1196w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The complete bit sequence is:<\/p>\n\n\n\n<div class=\"wp-block-math\"><math display=\"block\"><semantics><mrow><mn>000<\/mn><mtext>&nbsp;<\/mtext><mn>100<\/mn><mtext>&nbsp;<\/mtext><mn>101<\/mn><mtext>&nbsp;<\/mtext><mn>101<\/mn><mtext>&nbsp;<\/mtext><mn>11<\/mn><mtext>&nbsp;<\/mtext><mn>11<\/mn><mtext>&nbsp;<\/mtext><mn>001<\/mn><mtext>&nbsp;<\/mtext><mn>100<\/mn><mtext>&nbsp;<\/mtext><mn>010<\/mn><mtext>&nbsp;<\/mtext><mn>011<\/mn><mtext>&nbsp;<\/mtext><mn>11<\/mn><\/mrow><annotation encoding=\"application\/x-tex\">000\\ 100\\ 101\\ 101\\ 11\\ 11\\ 001\\ 100\\ 010\\ 011\\ 11<\/annotation><\/semantics><\/math><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Without separators, the result is:<\/p>\n\n\n\n<div class=\"wp-block-math\"><math display=\"block\"><semantics><mn>0001001011011111001100010001001111<\/mn><annotation encoding=\"application\/x-tex\">0001001011011111001100010001001111<\/annotation><\/semantics><\/math><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">For control: The individual codes must be read by the Huffman tree during decoding, as the code words are different in lengths.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Final conclusion<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The Huffman algorithm shows how data can be displayed in a space-saving manner by a clever arrangement of codes of different lengths.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-87724155 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"wp-block-paragraph translation-block\">Common characters such as <strong>E<\/strong> receive short codes, while rare characters receive longer codes. For the word <strong>KAFFEEPAUSE<\/strong> a Huffman tree is built step by step from the determined frequencies.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6aac12c8002a4&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6aac12c8002a4\" class=\"wp-block-image size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"537\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_fazit-edited.jpg\" alt=\"\" class=\"wp-image-1346\" srcset=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_fazit-edited.jpg 1024w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_fazit-edited-300x157.jpg 300w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_fazit-edited-768x403.jpg 768w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/08\/huffman_fazit-edited-18x9.jpg 18w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">If you then read the path from the root to each character, a unique code is created for each character. In this way, the word can be encoded without loss of information and decoded again later. The Huffman algorithm thus combines <strong>frequency analysis, tree structure and efficient data compression<\/strong>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Herk\u00f6mmliche Computercodes geben jedem Buchstaben starr denselben Speicherplatz \u2013 das h\u00e4ufige&nbsp;&#8218;E&#8216;&nbsp;verbraucht genauso viel wie das seltene&nbsp;&#8218;K&#8216;. Der&nbsp;Huffman-Algorithmus&nbsp;w\u00e4hlt einen clevereren Weg: H\u00e4ufige Zeichen bekommen sehr kurze Codes, seltene etwas l\u00e4ngere. So schrumpft die Datenmenge ohne jeden Informationsverlust. Wie aus Zeichenh\u00e4ufigkeiten Schritt f\u00fcr Schritt ein eleganter&nbsp;Huffman-Baum&nbsp;entsteht, schauen wir uns direkt am Beispielwort an:&nbsp;KAFFEEPAUSE.<\/p>","protected":false},"author":2,"featured_media":1313,"comment_status":"open","ping_status":"open","sticky":false,"template":"seite-thoughts-beitrag","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[89,88],"class_list":["post-1308","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-algorithms","tag-code","tag-huffman"],"_links":{"self":[{"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/posts\/1308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/comments?post=1308"}],"version-history":[{"count":0,"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/posts\/1308\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/media\/1313"}],"wp:attachment":[{"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/media?parent=1308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/categories?post=1308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/tags?post=1308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}