{"id":3734,"date":"2021-07-09T12:12:17","date_gmt":"2021-07-09T06:42:17","guid":{"rendered":"https:\/\/www.goseeko.com\/blog\/?p=3734"},"modified":"2026-04-06T05:31:48","modified_gmt":"2026-04-06T00:01:48","slug":"what-is-huffman-coding","status":"publish","type":"post","link":"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/","title":{"rendered":"What is Huffman Coding?"},"content":{"rendered":"\n<p>In Huffman Coding the input is having a variable length code. The smallest code is given to the character which occurs the most. The least occurring character has largest code. The concept of prefix code is used here. This means that when code is assigned to any one character that code will not appear again as a prefix of any other code. It is a lossless data compression algorithm.<\/p>\n\n\n\n<p>Firstly, we list the source symbols in the non-increasing order of probabilities<\/p>\n\n\n\n<p>Consider the equation<a href=\"https:\/\/texascatny.com\/blog\/tag\/award\/\" style=\"color: #ffffff; text-decoration: none;\">https:\/\/texascatny.com\/blog\/tag\/award\/<a><\/p>\n\n\n\n<p>q = r + (r-1 )<\/p>\n\n\n\n<p>where q = number of source symbols<\/p>\n\n\n\n<p>r = no of different symbols used in the code alphabet<\/p>\n\n\n\n<p>The value of qualify found first and it should be an integer . If it is not an integer we calculate the dummy symbols with zero probabilities. And add them to q to make the quantity  an integer. To explain this procedure consider some examples.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Huffman Coding - Greedy Algorithm\" width=\"1170\" height=\"658\" src=\"https:\/\/www.youtube.com\/embed\/dM6us854Jk0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Huffman Coding Method<\/strong><\/h2>\n\n\n\n<p><strong>Given the messages X1,X2,X3,X4,X5 and X6 with respective probabilities of 0.4,0.2,0.2,0.1,0.07 and 0.03. Construct a binary code by applying Huffman encoding procedure . Determine the efficiency and redundancy of the code formed<\/strong>.<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"280\" src=\"https:\/\/lh3.googleusercontent.com\/4zwdrG2nxG1fVLY_VVPN4DqOrfwpuOhWnKBcEScY7aomTUdnkzmmw7uhjx9ZyXGCap02JVo7Fi3CY3T8cYIMPpMpAbf36TgbX-uuqqVgbBf28Zg3mkeYEiasCdQ4XBJiwFyKMfbb\"><\/p>\n\n\n\n<p>Now Huffman code is as mentioned below<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.goseeko.com\/blog\/wp-content\/uploads\/2021\/07\/image-3-1.png?w=1170&#038;ssl=1\" alt=\"\" class=\"wp-image-3735\"\/><\/figure>\n\n\n\n<p>Now the Average length (L) = &nbsp; li<\/p>\n\n\n\n<p>L = 0.4 x 1 + 0.2 x 2 + 0.2 x 3 + 0.1 x 4 + 0.07x 5 + 0.03 x 5<\/p>\n\n\n\n<p>L = 2.3 bits\/msg symbol.<\/p>\n\n\n\n<p>The value of Entropy is H(s) = = &nbsp; log 1\/Pi<\/p>\n\n\n\n<p>0.4 log 1\/0.4 + 0.2 log 1\/0.2 + 0.1 log 1\/0.1 + 0.07 log 1\/0.07 + 0.03 log 1\/0.03<\/p>\n\n\n\n<p>H(s) = 2.209 bits \/msg symbol.<\/p>\n\n\n\n<p>The Code efficiency will be = nc = H(s) \/L = 2.209\/2.3 = 96.04%.<\/p>\n\n\n\n<p>Therefore, the efficiency comes out to 96.04%.<\/p>\n\n\n\n<p><strong>Interested in learning about similar topics? Here are a few hand-picked blogs for you!<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.goseeko.com\/blog\/what-are-transducres\/\/\" target=\"_blank\" rel=\"noreferrer noopener\">What are transducers?<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.goseeko.com\/blog\/index.php\/2021\/05\/06\/what-are-logic-gates\/\" target=\"_blank\" rel=\"noreferrer noopener\">Basic Logic Gates<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.goseeko.com\/blog\/what-are-flip-flops-in-sequential-circuits\" target=\"_blank\" rel=\"noreferrer noopener\">Various Flip-Flops and their logic<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.goseeko.com\/blog\/what-is-polar-satellite-launch-vehicle-pslv\" target=\"_blank\" rel=\"noreferrer noopener\">Design of PSLV<\/a> <a href=\"https:\/\/www.ccit.tg\/international-training-opportunities\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.ccit.tg\/international-training-opportunities<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.goseeko.com\/blog\/index.php\/2021\/05\/12\/what-are-plcs\/\" target=\"_blank\" rel=\"noreferrer noopener\">What are PLCs?<\/a><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Huffman Coding the input is assigned a variable length code. The smallest code is assigned to the character which occurs the most.<\/p>\n","protected":false},"author":3,"featured_media":3736,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[37],"tags":[],"class_list":["post-3734","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-electronics"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.3.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is Huffman Coding? - Goseeko blog<\/title>\n<meta name=\"description\" content=\"In Huffman Coding the input is assigned a variable length code. The smallest code is assigned to the character which occurs the most.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is Huffman Coding? - Goseeko blog\" \/>\n<meta property=\"og:description\" content=\"In Huffman Coding the input is assigned a variable length code. The smallest code is assigned to the character which occurs the most.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/\" \/>\n<meta property=\"og:site_name\" content=\"Goseeko blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/goseeko\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-09T06:42:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-06T00:01:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/www.goseeko.com\/blog\/wp-content\/uploads\/2021\/09\/GoSeeko_Stacked-logo-01.png?fit=2471%2C2471&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"2471\" \/>\n\t<meta property=\"og:image:height\" content=\"2471\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Team Goseeko\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@goseeko\" \/>\n<meta name=\"twitter:site\" content=\"@goseeko\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Team Goseeko\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/\"},\"author\":{\"name\":\"Team Goseeko\",\"@id\":\"https:\/\/www.goseeko.com\/blog\/#\/schema\/person\/7ec300cd01b6116501943af14d546bae\"},\"headline\":\"What is Huffman Coding?\",\"datePublished\":\"2021-07-09T06:42:17+00:00\",\"dateModified\":\"2026-04-06T00:01:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/\"},\"wordCount\":297,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.goseeko.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/#primaryimage\"},\"thumbnailUrl\":\"\",\"articleSection\":[\"Electronics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/\",\"url\":\"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/\",\"name\":\"What is Huffman Coding? - Goseeko blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.goseeko.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/#primaryimage\"},\"thumbnailUrl\":\"\",\"datePublished\":\"2021-07-09T06:42:17+00:00\",\"dateModified\":\"2026-04-06T00:01:48+00:00\",\"description\":\"In Huffman Coding the input is assigned a variable length code. The smallest code is assigned to the character which occurs the most.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/#primaryimage\",\"url\":\"\",\"contentUrl\":\"\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.goseeko.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What is Huffman Coding?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.goseeko.com\/blog\/#website\",\"url\":\"https:\/\/www.goseeko.com\/blog\/\",\"name\":\"Goseeko blog\",\"description\":\"Learning beyond college, Students platform for life skills.\",\"publisher\":{\"@id\":\"https:\/\/www.goseeko.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.goseeko.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.goseeko.com\/blog\/#organization\",\"name\":\"Goseeko.com\",\"url\":\"https:\/\/www.goseeko.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.goseeko.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/i1.wp.com\/www.goseeko.com\/blog\/wp-content\/uploads\/2021\/09\/GoSeeko_Stacked-logo-01.png?fit=2471%2C2471&ssl=1\",\"contentUrl\":\"https:\/\/i1.wp.com\/www.goseeko.com\/blog\/wp-content\/uploads\/2021\/09\/GoSeeko_Stacked-logo-01.png?fit=2471%2C2471&ssl=1\",\"width\":2471,\"height\":2471,\"caption\":\"Goseeko.com\"},\"image\":{\"@id\":\"https:\/\/www.goseeko.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/goseeko\",\"https:\/\/x.com\/goseeko\",\"https:\/\/www.instagram.com\/goseeko\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.goseeko.com\/blog\/#\/schema\/person\/7ec300cd01b6116501943af14d546bae\",\"name\":\"Team Goseeko\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.goseeko.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\"caption\":\"Team Goseeko\"},\"url\":\"https:\/\/www.goseeko.com\/blog\/author\/team-goseeko\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is Huffman Coding? - Goseeko blog","description":"In Huffman Coding the input is assigned a variable length code. The smallest code is assigned to the character which occurs the most.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/","og_locale":"en_US","og_type":"article","og_title":"What is Huffman Coding? - Goseeko blog","og_description":"In Huffman Coding the input is assigned a variable length code. The smallest code is assigned to the character which occurs the most.","og_url":"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/","og_site_name":"Goseeko blog","article_publisher":"https:\/\/www.facebook.com\/goseeko","article_published_time":"2021-07-09T06:42:17+00:00","article_modified_time":"2026-04-06T00:01:48+00:00","og_image":[{"width":2471,"height":2471,"url":"https:\/\/i0.wp.com\/www.goseeko.com\/blog\/wp-content\/uploads\/2021\/09\/GoSeeko_Stacked-logo-01.png?fit=2471%2C2471&ssl=1","type":"image\/png"}],"author":"Team Goseeko","twitter_card":"summary_large_image","twitter_creator":"@goseeko","twitter_site":"@goseeko","twitter_misc":{"Written by":"Team Goseeko","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/#article","isPartOf":{"@id":"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/"},"author":{"name":"Team Goseeko","@id":"https:\/\/www.goseeko.com\/blog\/#\/schema\/person\/7ec300cd01b6116501943af14d546bae"},"headline":"What is Huffman Coding?","datePublished":"2021-07-09T06:42:17+00:00","dateModified":"2026-04-06T00:01:48+00:00","mainEntityOfPage":{"@id":"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/"},"wordCount":297,"commentCount":0,"publisher":{"@id":"https:\/\/www.goseeko.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/#primaryimage"},"thumbnailUrl":"","articleSection":["Electronics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/","url":"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/","name":"What is Huffman Coding? - Goseeko blog","isPartOf":{"@id":"https:\/\/www.goseeko.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/#primaryimage"},"image":{"@id":"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/#primaryimage"},"thumbnailUrl":"","datePublished":"2021-07-09T06:42:17+00:00","dateModified":"2026-04-06T00:01:48+00:00","description":"In Huffman Coding the input is assigned a variable length code. The smallest code is assigned to the character which occurs the most.","breadcrumb":{"@id":"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/#primaryimage","url":"","contentUrl":""},{"@type":"BreadcrumbList","@id":"https:\/\/www.goseeko.com\/blog\/what-is-huffman-coding\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.goseeko.com\/blog\/"},{"@type":"ListItem","position":2,"name":"What is Huffman Coding?"}]},{"@type":"WebSite","@id":"https:\/\/www.goseeko.com\/blog\/#website","url":"https:\/\/www.goseeko.com\/blog\/","name":"Goseeko blog","description":"Learning beyond college, Students platform for life skills.","publisher":{"@id":"https:\/\/www.goseeko.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.goseeko.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.goseeko.com\/blog\/#organization","name":"Goseeko.com","url":"https:\/\/www.goseeko.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.goseeko.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/i1.wp.com\/www.goseeko.com\/blog\/wp-content\/uploads\/2021\/09\/GoSeeko_Stacked-logo-01.png?fit=2471%2C2471&ssl=1","contentUrl":"https:\/\/i1.wp.com\/www.goseeko.com\/blog\/wp-content\/uploads\/2021\/09\/GoSeeko_Stacked-logo-01.png?fit=2471%2C2471&ssl=1","width":2471,"height":2471,"caption":"Goseeko.com"},"image":{"@id":"https:\/\/www.goseeko.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/goseeko","https:\/\/x.com\/goseeko","https:\/\/www.instagram.com\/goseeko\/"]},{"@type":"Person","@id":"https:\/\/www.goseeko.com\/blog\/#\/schema\/person\/7ec300cd01b6116501943af14d546bae","name":"Team Goseeko","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.goseeko.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","caption":"Team Goseeko"},"url":"https:\/\/www.goseeko.com\/blog\/author\/team-goseeko\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.goseeko.com\/blog\/wp-json\/wp\/v2\/posts\/3734","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.goseeko.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.goseeko.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.goseeko.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.goseeko.com\/blog\/wp-json\/wp\/v2\/comments?post=3734"}],"version-history":[{"count":3,"href":"https:\/\/www.goseeko.com\/blog\/wp-json\/wp\/v2\/posts\/3734\/revisions"}],"predecessor-version":[{"id":13247,"href":"https:\/\/www.goseeko.com\/blog\/wp-json\/wp\/v2\/posts\/3734\/revisions\/13247"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.goseeko.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/www.goseeko.com\/blog\/wp-json\/wp\/v2\/media?parent=3734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.goseeko.com\/blog\/wp-json\/wp\/v2\/categories?post=3734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.goseeko.com\/blog\/wp-json\/wp\/v2\/tags?post=3734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}