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

Huffman with C , segmentation default (core dumped)

I tried to implement huffman algorithm with C using a binary tree and 2 queues : #include #include #include #include #define L 71/*Letters in the alphabet*/ typedef struct Node Node; struct Node { …
akram1rekik
  • 153
  • 1
  • 1
  • 7
-1
votes
1 answer

Adaptive (dynamic) Huffman Coding: encode and decode data from file

i am writing right now program thats should encode/decode data from file. Alphabet: 8-bit ASCII codes So i have n = 256 symbols in this alphabet, max number of heaps is 2n-1 = 511 I understand algorithm of adaptive huffman coding but i have some…
-1
votes
1 answer

Bit Manipulation (Cutting down bits)

Given that a byte is 8 bits, and a character is 1 byte, Is there any way to manipulate an array of characters (a string), such that we may be able to represent each character in the string into a more compacted number of bits (say 5 bits?)
-1
votes
1 answer

Java Creating a Huffman Tree

I'm currently in the process of creating a Huffman Tree using a Priority Queue. I understand the concept of how the Huffman Tree works, however while implementing it I have been finding it difficult to produce the code. Currently I have this: public…
Craig
  • 675
  • 1
  • 7
  • 23
-1
votes
2 answers

Is there a way to restore frequency array from Huffman tree?

Most people, when they implement study Huffman algorithm, prefer to store frequency array, not Huffman tree. But sometimes I would like to store Huffman tree. For example, It allows immediately decode data. Unfortunately, I do not know, how to…
Max
  • 1,803
  • 3
  • 25
  • 39
-1
votes
2 answers

Storing table of codes in a compressed file after Huffman compression and building tree for decompression from this table

I was writing a program of Huffman compression using C++ but I faced with a problem of compressed file's structure. It needs to store some structure in my new file that can help me to decode this file. I decided to write a table of codes in the…
Lex
  • 13
  • 2
-1
votes
1 answer

Decoding using huffman code

I created a program to read a file and encodes it character by character into a variable length binary code. ex. the most common character would be 110, next common 0010, etc. I then put the entire binary code into a text file. So the code would…
user1798299
  • 173
  • 2
  • 4
  • 12
-1
votes
1 answer

How can I read non-ascii characters from a file in C?

I am right now reading in like this: while (fscanf(in, "%c", infile) != EOF) { ch = *infile; count++; ascii[ch]++; } And making my frequency table like this: void frequency () { unsigned long long i; for (i…
user3366369
  • 13
  • 1
  • 8
-1
votes
1 answer

Compress image using Huffman coding in Java

So, I have been breaking my head over huffman coding compression for "IMAGES". I know the working of huffman and am able to implement on text, however, I do not understand how do I proceed further with images. I have a grayscale image, which I…
Polynomial Proton
  • 5,020
  • 20
  • 37
-1
votes
1 answer

How can I decode/encode huffman trees in zlib?

I have been searching the internet but could not find any information on how to use zlib in MSVC++ for encoding/decoding a huffman tree. Question: How can I use zlib to decode and encode a huffman tree. Also, is there anyway to identify that a…
user1328762
  • 129
  • 1
  • 2
  • 10
-1
votes
1 answer

Huffman Coding Compression

I have a file of 100 MB and it was compressed by huffman coding 20 times. I want to draw a diagram for the changes of the size of the file while compressing it, so the x axis will have the number of compression times, and the y axis is the size of…
Adly
  • 597
  • 3
  • 12
  • 23
-1
votes
1 answer

Huffman Algorithm is meant for what types of data?

I have been reading about this algorithm, and i understand building the tree, and what the output should be at the end of the tree process. All the examples are of text files, but for other types of files, you need to read it as a binary file ? In…
Pedro
  • 41
  • 9
-1
votes
1 answer

I have created the huffman tree but im having issues in generating the codes out ouf it

Here is my function, i seed it with the root node of my tree and a character to be found inside the tree. It successfully returns me the alphabet to be searched but it does not give me the path to the element. Im a bit stuck any help would be…
-1
votes
1 answer

Recursive function in Huffman Decoding not exiting

I am having a bit of trouble with my Huffman Decoding function I have created. I was just wondering if anyone knew why my program was producing an infinite loop. Below is my function and how I caled it. When counter hits 8, it should exit out of the…
user200081
  • 563
  • 2
  • 12
  • 24
-1
votes
2 answers

Could anyone tell me why my code is producing an error?

I have a Huffman Tree, and a character, and I want to return what that character's encoding within the Huffman Tree should be. I've implemented it using the breadth-first traversal method, and each time I'm checking the left and right tree, I'm…
Doug Smith
  • 29,668
  • 57
  • 204
  • 388