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

What is a faster way of compressing this data?

I have a program that computes a ton of data and writes it to a file. My data is just a bunch of numbers from 0-16 (17 different values), and I have computed the frequency that each number appears in the data. I need to use as little disk space and…
Broseph
  • 1,655
  • 1
  • 18
  • 38
3
votes
1 answer

How to advance past a deflate byte sequence contained in a byte stream?

I have a byte stream that is a concatenation of sections, where each section is composed of a header plus a deflated byte stream. I need to split this byte stream sections but the header only contains information about the data in uncompressed…
Thiago Padilha
  • 4,590
  • 5
  • 44
  • 69
3
votes
1 answer

Huffman Code - Segmentation Fault 11

Ok I have tried to make the Hauffman Code by my own and I have a problem when I'm trying to print the corresponding code to each letter with a recursive method. (By this point I already created a BinaryTree and root is not NULL) Each node has a…
3
votes
3 answers

How do generate this Huffmann Tree (similar to binary trees)

I understand how to create Huffmann trees when the frequencies are different to each other but how would I draw this huffmann tree if few of the frequencies are the same: simple explanation of the Huffmann trees is found here The data of the…
Bic B
  • 201
  • 2
  • 6
  • 18
2
votes
2 answers

Poor mans Huffman Compression

Im trying to better understand how the huffman decoder works. Ive got a code table but im having a hard time trying to understand how the decoder would work because of ambiguity in the binary string. (im learning this in prep for my final year at…
Gelion
  • 531
  • 7
  • 18
2
votes
2 answers

Writing the huffman tree to file after compression

I'm trying to write a Huffman tree to the compressed file after all the actual compressed file data has been inserted. But , i just realized a bit of a problem , suppose I decide that once all my actual data has been written to file , I will put in…
angryInsomniac
  • 829
  • 2
  • 13
  • 27
2
votes
1 answer

Huffman table entropy decoding simplification (in C)

First time using this site to ask a question, but I have gotten many many answers! Background: I am decoding a variable length video stream that was encoded using RLE and Huffman encoding. The stream is 10 to 20 Kilobytes long and therefore I am…
Tim Z
  • 21
  • 2
2
votes
1 answer

Generating AC elements from jpeg file

I'm decoding jpeg file. I have generated huffman tables, and quantization tables, and I have reach the point where I have to decode DC and AC elements. For example lets say I have next data FFDA 00 0C 03 01 00 02 11 03 11 00 3F 00 F2 A6 2A FD 54 C5…
MrD
  • 2,423
  • 3
  • 33
  • 57
2
votes
1 answer

8086 - storing command line arguments in arrays

I'm writing an encoding/decoding .COM program using Huffman algorithm for dos 8086 (16-bit tasm or masm without using libraries), and need to store 2 command-line arguments (inputfilename and outputfilename) in arrays so that I can read the input…
ratsimihah
  • 1,010
  • 1
  • 11
  • 22
2
votes
1 answer

How to do Huffman encoding of base 3

I have a problem in my program implement Huffman encoding. In base 2, I use a binary tree to store codeword, but I don't know how to deal with base 3. I'm trying to use a trinary tree, but don't know how to implement it with a trinary, how to add…
hienvd
  • 346
  • 1
  • 5
  • 17
2
votes
2 answers

Efficient Huffman tree search while remembering path taken

As a follow up question related to my question regarding efficient way of storing huffman tree's I was wondering what would be the fastest and most efficient way of searching a binary tree (based on the Huffman coding output) and storing the path…
X-Istence
  • 16,324
  • 6
  • 57
  • 74
2
votes
1 answer

HuffmanCode fixed bits length per character

How do you determine how many bits per character are required for a fixed length code in a string using huffman? i had an idea that you count the number of different characters in a string than you present that number in binary so that will be the…
ac3hole
  • 123
  • 2
  • 10
2
votes
1 answer

How to get arrange a Huffman Tree in a specific way

I have a assignment that requires me to do Huffman encoding, but my results don't line up with the expected output. // Huffman Coding in C #include #include #define MAX_TREE_HT 50 struct MinHNode { char item; unsigned…
Narcisismo
  • 23
  • 4
2
votes
2 answers

Generating a Huffman code that never produces the string "00" upon encoding

I am trying to use Huffman coding to create an optimal coding for a set of symbols. However, a constraint is placed on the encodings such that no encoding contains the string, "00". For example, the encoding 'A' = '0' and 'B' = '10' would not…
1um0
  • 23
  • 4
2
votes
1 answer

Huffman Decoding Sub-Table

I've been trying to implement a huffman decoder, and my initial attempt suffered from low performance due to a sub-optimal choice of decoding algorithm. I thought I try to implement huffman decoding using table-lookups. However, I go a bit stuck on…
ronag
  • 49,529
  • 25
  • 126
  • 221