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
2
votes
1 answer

Lossless data compression in C without dynamic memory allocation

I'm currently trying to implement a lossless data compression algorithm for a project I'm working on. The goal is to compress a fixed size list of floating point values. The code has to be written in C and can NOT use dynamic memory allocation. This…
xDranik
  • 231
  • 1
  • 3
  • 8
2
votes
2 answers

Seekg(ios::beg) not returning to beginning of redirected input

I am making a huffman encoder and to do so i need to read over the input (which will ALWAYS be a redirected file) to record the frequencies, then create the codebook and then read over the input again so i can encode it. My problem is that i am…
user0123
  • 259
  • 1
  • 6
  • 17
2
votes
4 answers

Huffman Tree in Java

I have a problem with my Huffman tree code. In the main method I input a String of Symbols and I also input an Integer array containing the frequency of the Symbols. It should print out each Symbol and its Huffman code, but I think its wrong...…
user2403221
  • 435
  • 1
  • 3
  • 12
2
votes
1 answer

huffman coding for a text file

This is only part of my huffman tree generated using ocaml. The tree is represented as (char*int list) list: [(' ', [0]); ('e', [1; 0]); ('t', [1; 1; 0]); ('a', [1; 1; 1; 0]); ('o', [1; 1; 1; 1; 0]); ('n', [1; 1; 1; 1; 1; 0]).....]. The (char*int…
user2390930
  • 137
  • 1
  • 2
  • 10
2
votes
2 answers

Splitting sequence of 1's and 0's into byte

I am currently working on huffman decoding. I have a String representation of all the character encodings(i.e "1101000100000001"). I am trying to split it into groups of 8 and return its corresponding value(i.e. "11010001" would return 209). However…
somtingwong
  • 361
  • 1
  • 6
  • 19
2
votes
3 answers

compression algorithm for street names wanted

I have a list of millions of street names and want to compress them using a compression algorithm. I am not sure which algorithm would fit best. Most street names have common substrings in them, such as for example "street", "way", ... The set of…
Christian
  • 4,345
  • 5
  • 42
  • 71
2
votes
3 answers

C++, Storing a String containing binary into a text file

I am currently attempting to store a string containing binary code. When I attempt to write this string to a text file it simply stores each 0 and 1 character in a string format, rather than storing it into 8 bit chunks as I require. This causes…
2
votes
3 answers

Efficient compression and representation of key value pairs to be read from 1D barcodes

I'm currently writing an application for Windows Mobile which needs to be able to pick up key value pairs from 1D barcodes (configuration settings). The less barcodes need to be scanned, the better. Sample input: ------------------------------ | Key…
Gene
  • 4,192
  • 5
  • 32
  • 56
2
votes
1 answer

Huffman minimum variance coding

it is well known that Huffman code with minimum variance is preferable. I've digged through entire Polish/English internet and this is what I found: to build Huffman code with minimum variance you need to break ties with one of the following methods…
Piotr Jaszkowski
  • 1,150
  • 9
  • 12
2
votes
2 answers

Bit Array to String and back to Bit Array

Possible Duplicate Converting byte array to string and back again in C# I am using Huffman Coding for compression and decompression of some text from here The code in there builds a huffman tree to use it for encoding and decoding. Everything works…
Gopikrishna S
  • 2,221
  • 4
  • 25
  • 39
2
votes
1 answer

How is this Huffman Table created?

I have a table that shows the probability of an event happening. I'm fine with part 1, but part 2 is not clicking with me. I'm trying to get my head around how the binary numbers are derived in part 2? I understand 0 is assigned to the largest…
2
votes
2 answers

Approximate Order-Preserving Huffman Code

I am working on an assignment for an Algorithms and Data Structures class. I am having trouble understanding the instructions given. I will do my best to explain the problem. The input I am given is a positive integer n followed by n positive…
Osuvaldo
  • 274
  • 3
  • 10
2
votes
1 answer

function wont accept iterator to auto_ptr

I wrote some flawed Huff compression code that I was trying to fix. The first thing I did was to switch the pointers to auto_ptr (There are reasons I didn't use another smart pointer). I create a vector of auto_ptr but when I try to pass an auto_ptr…
sinθ
  • 11,093
  • 25
  • 85
  • 121
2
votes
3 answers

What is the advantage of a full binary tree for Huffman code?

I am studying Huffman code for bit encoding a stream of characters and read that an optimal code would be represented by a full binary tree where each distinct character is represented by a leaf and all internal nodes contain exactly two children .…
Geek
  • 26,489
  • 43
  • 149
  • 227
2
votes
2 answers

error in sending image from android to java app serially -javax.imageio.IIOException: Bogus Huffman table definition

I need to send image from android app to java app. Basically, I need a byte array from the image to send to rf module which transmits.Another rf module receives and sends the byte array to java app which must make the image . Android…
Samyuktha
  • 31
  • 5