This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple Huffman Code decomposition

 
Scott Grant
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!
I just picked up a java for beginners class - I'm about 3 weeks late, however, so I'm a bit behind. I'm reading as much as I can, and have figured out quite a bit of the visual side, fiddling with applets and stuff. For some reason it's the stuff that's supposed to be simple that I'm just not figuring out.
I need to decompress a Huffman code (1100111001000100011110110 for example). Binary tree algorithms and other such complex (to me!) code wouldn't help me, since I wouldn't know what I was looking at - I was thinking more along the lines of a simple (albeit unrealistic, it's allowed!) switch statement to decompress the code.
Anyone able to help me out?
Thanks!
Scott
 
Scott Grant
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's an array I put together, would this work? (I only included the first 5 letters of the code to save space). My only issue is I haven't included a null option, because 0 is a part of the code. I know.. total newbie issues.
 
Stevie Aldrich
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's your algorithm to decompress the code? Do you have any pseudo code?
The posted code doesn't look like it will compile because of undeclared variable m. Should that be c ?
Also, what is the result of code[110]="b". It looks to me like you're trying to assign string "b" to the one hundred tenth element of a 13 element array.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic