Click here to Skip to main content
15,920,053 members
Home / Discussions / Java
   

Java

 
QuestionNoob question Pin
jharker198719-Apr-09 7:11
jharker198719-Apr-09 7:11 
AnswerRe: Noob question Pin
fly90419-Apr-09 8:17
fly90419-Apr-09 8:17 
GeneralRe: Noob question Pin
jharker198719-Apr-09 8:48
jharker198719-Apr-09 8:48 
GeneralRe: Noob question Pin
fly90419-Apr-09 9:56
fly90419-Apr-09 9:56 
QuestionHuffman coding in Java Script Encoding Decoding Pin
novhard19-Apr-09 4:35
novhard19-Apr-09 4:35 
AnswerRe: Huffman coding in Java Script Encoding Decoding Pin
MikeMarq19-Apr-09 5:13
MikeMarq19-Apr-09 5:13 
GeneralRe: Huffman coding in Java Script Encoding Decoding Pin
novhard19-Apr-09 6:33
novhard19-Apr-09 6:33 
GeneralRe: Huffman coding in Java Script Encoding Decoding Pin
MikeMarq19-Apr-09 8:20
MikeMarq19-Apr-09 8:20 
I'll have to find the usb drive I have it on since I did it a little while ago. Hopefully I'll find it by tommorrow and post the code so you can see it.

But here's an explaination of how it works (please note if you don't know what a tree, structure, or linked list is I would suggest reading the wikipedia articles to learn that first since huffman uses them):

Suppose you had a long text file where all the letters were either an A,B,C,or D and you wanted to save them in the minumum space possible. Also suppose you knew that 80% were A, 15% were B, 3% were C, 2% were D. You could give each letter a 2 digit binary code but that would not be as efficient as giving the most commons letter(s) a shorter binary code even if this means the less common ones have to be slightly longer code.

For instance huffman would give them these codes:

A = 0
B = 10
C = 110
D = 111

It creates these codes by creating an unbalanced binary tree. To do this you create a list of nodes that are placed in order according to frequency. Then you remove the 2 least common nodes and create a parent node for them that contains the frequency of both nodes and place the parent node back into the list in order. You keep doing this till you have only 1 node and that node is your root node.

Here's what the tree looks like:

Root...................................(ABCD Freq 100%)
Level 1..........(A Freq 80% Code 0)..................(BCD Freq 20%)
Level 2...............................(B Freq 15% Code 10).........(CD Freq 5%)
Level 3.............................................(C Freq %3 Code 110)..(D Freq 2% Code 111)

The codes are determinded by where the node is on the tree. Left is 0 right is 1. To encode you create the tree and write the binary code for each symbol. To decode you start at the root and go left if the number is 0 and right if it is 1. You continue doing this until you reach a leaf node. Once you reach a leaf node you write the letter and start again at the root.
GeneralRe: Huffman coding in Java Script Encoding Decoding Pin
novhard19-Apr-09 18:39
novhard19-Apr-09 18:39 
GeneralRe: Huffman coding in Java Script Encoding Decoding [modified] Pin
MikeMarq20-Apr-09 6:37
MikeMarq20-Apr-09 6:37 
GeneralThe code Pin
MikeMarq20-Apr-09 6:41
MikeMarq20-Apr-09 6:41 
GeneralThe encripted file Pin
MikeMarq20-Apr-09 6:43
MikeMarq20-Apr-09 6:43 
GeneralSymbol Frequencies Pin
MikeMarq20-Apr-09 6:44
MikeMarq20-Apr-09 6:44 
GeneralRe: Huffman coding in Java Script Encoding Decoding Pin
novhard21-Apr-09 18:53
novhard21-Apr-09 18:53 
QuestionDisplaying Text on a JFrame Pin
MikeMarq18-Apr-09 11:22
MikeMarq18-Apr-09 11:22 
QuestionHow to display Time for an Online Test Pin
kaushal kishore sharma16-Apr-09 19:31
kaushal kishore sharma16-Apr-09 19:31 
QuestionJava Video Player Pin
Flying_Doc16-Apr-09 16:00
Flying_Doc16-Apr-09 16:00 
AnswerRe: Java Video Player Pin
vctrlao23-Apr-09 20:39
vctrlao23-Apr-09 20:39 
QuestionHow to log into a web site with a certificate. Pin
werpa13-Apr-09 11:03
werpa13-Apr-09 11:03 
Questiongetting text from radio button Pin
Vishnu Prem12-Apr-09 20:12
Vishnu Prem12-Apr-09 20:12 
AnswerRe: getting text from radio button Pin
vctrlao23-Apr-09 20:41
vctrlao23-Apr-09 20:41 
QuestionHow can i get special folder icon ? Pin
anbluemoon12-Apr-09 1:44
anbluemoon12-Apr-09 1:44 
AnswerRe: How can i get special folder icon ? Pin
fly90412-Apr-09 5:02
fly90412-Apr-09 5:02 
Question[Message Deleted] Pin
kaushal kishore sharma10-Apr-09 0:01
kaushal kishore sharma10-Apr-09 0:01 
AnswerRe: making Proxy server by using Java Pin
Nagy Vilmos11-Apr-09 0:40
professionalNagy Vilmos11-Apr-09 0:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.