3 Replies - 1528 Views - Last Post: 19 April 2011 - 09:17 PM Rate Topic: -----

#1 lesfleurs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 19-September 10

Huffman Encoding

Posted 19 April 2011 - 05:00 PM

I am writing a program to compress text files using huffman encoding so far everything works right. However I have to now figure out how to write the prefix codes so they can be compressed. This involves converting them to their ascii equivalent after they have been written in chunks of eight bits. Can anyone tell me how to compress the prefix codes. right now they are being returned as strings e.g 'a' might be encoded as 010 but it still needs to be compressed

Is This A Good Question/Topic? 0
  • +

Replies To: Huffman Encoding

#2 dukky  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 111
  • Joined: 28-November 09

Re: Huffman Encoding

Posted 19 April 2011 - 05:30 PM

not exactly understading what you mean by prefix codes? give an example of one and how you want to compress it?
Was This Post Helpful? 0
  • +
  • -

#3 lesfleurs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 19-September 10

Re: Huffman Encoding

Posted 19 April 2011 - 06:02 PM

A prefix code is the one generated by the Hoffman Tree when you searched for a character within the tree
for example "a" could equal "0101010"
however I cannot write that to a file because it is a string of 7 characters which would possess more bits than the characters i tried to compress to begin with and so i have to convert that string to a decimal number and then convert that decimal number to its ASCII character equivalent. Then that ASCII character can be written to an output file and so for a sufficient number of characters, the data would be compressed.

I actually just wrote the function to convert to decimal. However I need a way to convert to its ASCII equivalent. I am not allowed to use the itoA function as the linux compiler won't accept it so i need pointers on how to write my own
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10486
  • View blog
  • Posts: 38,858
  • Joined: 27-December 08

Re: Huffman Encoding

Posted 19 April 2011 - 09:17 PM

The compression comes in when you write the prefix codes as the path to find the character in the Tree, rather than as eight bits. The whole point of the encoding is so you don't have to write the ASCII characters to the File. Or am I missing something in what you are trying to accomplish? :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1