Questions tagged [huffman-code]

Huffman coding is a lossless compression algorithm that is optimal, assuming all input characters are drawn from a known discrete distribution.

Huffman coding is an algorithm that builds a variable-length, prefix-free code for each character in an alphabet based on the frequency of that character. The algorithm works by greedily assembling an encoding tree by combining together encoding trees for individual characters based on their weights. Low-weight trees are combined together until only a single tree remains.

Useful links

1053 questions
3
votes
2 answers

Decoding a Huffman code with a dictionary

I need to decode a Huffman code I coded with my program using a file containing the translation beetween ASCII and Huffman bits. I have already a dictionary in the progam from "codes" to ASCII like this one: {'01110': '!', '01111': 'B', '10100':…
Matt Rest
  • 63
  • 1
  • 1
  • 4
3
votes
1 answer

Minimum description length and Huffman coding for two symbols?

I am confused about the interpretation of the minimum description length of an alphabet of two symbols. To be more concrete, suppose that we want to encode a binary string where 1's occur with probability 0.80; for instance, here is a string of…
3
votes
4 answers

Java - Need help with binary/code string manipulation

For a project, I have to convert a binary string into (an array of) bytes and write it out to a file in binary. Say that I have a sentence converted into a code string using a huffman encoding. For example, if the sentence was: "hello" h = 00 e =…
ShrimpCrackers
  • 4,388
  • 17
  • 50
  • 76
3
votes
3 answers

Huffman coding two characters as one

I need huffman code(best in python or in java), which could encode text not by one character (a = 10, b = 11), but by two (ab = 11, ag = 10). Is it possible and if yes, where could i find it, maybe it's somewhere in the internet and i just can'd…
Adomas
  • 289
  • 2
  • 4
  • 16
3
votes
1 answer

Dealing with Padding / Stuff Bits Entropy Encoded JPEG

When decoding entropy encoded DC values in JPEG (or the entropy encoded prediction differences in lossless JPEG), how do I distinguish between 1 bits that have been stuffed to pad a byte before a marker and a Huffman coded value? For example if I…
Alex Rothberg
  • 10,243
  • 13
  • 60
  • 120
3
votes
2 answers

Examples of Deflate Compression

I am interested in learning about the deflate compression algorithm, particularly how is it represented in a data-stream, and feel that I would greatly benefit from some extra examples (eg. the compression of a short string of text, or the…
user3672051
3
votes
3 answers

Priority Queue Wrong Order

I am programming the huffman encoding. This is the beginning of my program: using namespace std; //Counting methods int *CountCharOccurence(string text) { int *charOccurrence = new int[127]; for(int i = 0; i < text.length(); i++) { …
3
votes
2 answers

binary prefix code in huffman algorithm

In the huffman coding algorithm, there's a lemma that says: The binary tree corresponding to an optimal binary prefix code is full But I can't figure out why. How can you prove this lemma?
Kadaj13
  • 1,423
  • 3
  • 17
  • 41
3
votes
2 answers

How to read a binary file to calculate frequency of Huffman tree?

I have to calculate frequency of Huffman tree from a "binary file" as sole argument. I have a doubt that binary files are the files which contains "0" and "1" only. Whereas frequency is the repetition of the number of alphabets (eg, abbacdd here…
Sss
  • 1,519
  • 8
  • 37
  • 67
3
votes
7 answers

Why Huffman Coding is good?

I am not asking how Huffman coding is working, but instead, I want to know why it is good. I have the following two questions: Q1 I understand the ultimate purpose of Huffman coding is to give certain char a less bit number, so space is saved. What…
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
3
votes
1 answer

Queues and multiprocessing

I am writing some code to build a table of variable length (Huffman) codes, and I wanted to use the multiprocessing module for fun. The idea is to have each process try to get a node from the queue. They do work on the node, and either put that…
Broseph
  • 1,655
  • 1
  • 18
  • 38
3
votes
2 answers

Huffman encoding issue

As an exercise I'm trying to encode some symbols using Huffman trees, but using my own class instead of the built in data types with Python. Here is my node class: class Node(object): left = None right = None weight = None data =…
Tom Kealy
  • 2,537
  • 2
  • 27
  • 45
3
votes
2 answers

Deterministic and non uniform long string generation from seed

I had this weird idea for an encryption that I wanted to try out, it may be bad, and it may have done before, but I'm just doing it for fun. The short version of the question is: Is it possible to generate a long, deterministic and non-uniformly…
Limon
  • 963
  • 2
  • 10
  • 23
3
votes
1 answer

DEFLATE Encoding with static Huffman Codes

need some help to understand how DEFLATE Encoding works. I know that is a combination of the LZSS algorithm and Huffman coding. So let encode for example "Deflate late". Params: [Search buffer: 8kb and Look-ahead buffer 4kb] Well, the output of LZSS…
FewG
  • 33
  • 1
  • 4
3
votes
3 answers

Huffman coding is based on what Greedy Approach or Dynamic Programming

Can we solve Problem of Huffman Coding by using Dynamic Programming, Is there any algorithm
user2375464