Questions tagged [huffman-encoding]

11 questions
8
votes
5 answers

How to discriminate from two nodes with identical frequencies in a Huffman's tree?

Still on my quest to compress/decompress files with a Java implementation of Huffman's coding (http://en.wikipedia.org/wiki/Huffman_coding) for a school assignment. From the Wikipedia page, I quote: Create a leaf node for each symbol and add it to…
Saturn
  • 3,887
  • 9
  • 30
  • 40
5
votes
2 answers

finding optimal token definitions for compression

I have a collection of strings which have a lot of common substrings, and I'm trying to find a good way to define tokens to compress them. For instance, if my strings are: s1 = "String" s2 = "Bool" s3 = "String -> Bool" s4 = "String -> String" s5 =…
ErikR
  • 296
  • 1
  • 4
2
votes
4 answers

Reconstructing a huffman tree using minimal information in the header

I'm writing a huffman encoding program in C. I'm trying to include the least amount of information in the header as possible, I know the simplest way to decompress the file in the header would be to store the frequencies of each character in the…
shoham
  • 225
  • 4
  • 9
2
votes
2 answers

How do I find average bits per symbol using huffman code?

I'm trying to write a program in c for Huffman coding, but I am stuck. For input I have: Sample input: 4 // here I scan how many letters I have A 00 // and for everyone I scan how they are coded in string down B 10 C 01 D…
Maria
  • 29
  • 1
  • 1
  • 2
2
votes
1 answer

Does it matter the direction of a Huffman's tree child node?

So, I'm on my quest about creating a Java implementation of Huffman's algorithm for compressing/decompressing files (as you might know, ever since Why create a Huffman tree per character instead of a Node?) for a school assignment. I now have a…
Saturn
  • 3,887
  • 9
  • 30
  • 40
2
votes
1 answer

Why create a Huffman tree per character instead of a Node?

For a school assignment we're supposed to make a Java implementation of a compressor/decompresser using Huffman's algorithm. I've been reading a bit about it, specially this C++ tutorial:…
Saturn
  • 3,887
  • 9
  • 30
  • 40
1
vote
0 answers

Calculating uncompressed file size without uncompressing file in zlib

I am writing a python program which parses zip (currently only zlib, using DEFLATE compression) files and verifies the correctness of their headers and data. One of the things I'm trying to achieve is calculating the uncompressed size of a…
S B
  • 11
  • 3
1
vote
0 answers

Encode Optimal Huffman code

I have given message encoded with non-optimal Huffman code. I need to decode the message and encode it again, but this time with optimal Huffman code, so after that I can find average_number_of_bits_per_symbols = num_of_bits_in_message /…
1
vote
1 answer

How should I compress a file with multiple bytes that are the same with Huffman coding?

On my great quest for compressing/decompressing files with a Java implementation of Huffman coding (http://en.wikipedia.org/wiki/Huffman_coding) for a school assignment, I am now at the point of building a list of prefix codes. Such codes are used…
Saturn
  • 3,887
  • 9
  • 30
  • 40
0
votes
1 answer

Binary Tree and Variable Length Codes for given Alphabets using Huffman Encoding (Confusion)

Last week our teacher gave us a question about Huffman Encoding Algorithm described as below. HUFFMAN ENCODING ALGORITHM: Consider all pairs: . Choose the two lowest frequencies, and make them brothers, with the root having the combined…
0
votes
0 answers

how to find average bits per symbol using huffman code?

I'm trying to write a program in c for Huffman coding, but i stack.In input i have: Sample input: 4 //here i scan how many letters i have A 00 // and for everyone i scan how they are coded in string down B 10 C 01 D…
Maria
  • 29
  • 1
  • 1
  • 2