Click here to Skip to main content
15,887,746 members
Home / Discussions / C#
   

C#

 
GeneralRe: Access Denied Pin
Julian Bucknall [MSFT]23-Jul-03 13:59
Julian Bucknall [MSFT]23-Jul-03 13:59 
GeneralRe: Access Denied Pin
Alexandru Serban23-Jul-03 19:55
professionalAlexandru Serban23-Jul-03 19:55 
Generalhuffman tree algorithm Pin
jtmtv1823-Jul-03 11:23
jtmtv1823-Jul-03 11:23 
GeneralRe: huffman tree algorithm Pin
totig23-Jul-03 13:27
totig23-Jul-03 13:27 
GeneralRe: huffman tree algorithm Pin
Julian Bucknall [MSFT]23-Jul-03 13:41
Julian Bucknall [MSFT]23-Jul-03 13:41 
GeneralRe: huffman tree algorithm Pin
jtmtv1823-Jul-03 14:46
jtmtv1823-Jul-03 14:46 
GeneralRe: huffman tree algorithm Pin
Frank Olorin Rizzi24-Jul-03 4:11
Frank Olorin Rizzi24-Jul-03 4:11 
GeneralRe: huffman tree algorithm Pin
Julian Bucknall [MSFT]24-Jul-03 8:48
Julian Bucknall [MSFT]24-Jul-03 8:48 
So it's more than just building the tree, then?

Building the tree is the standard well-understood algorithm. Using the tree is where things diverge and get really tough. To compress using a huffman tree, you have to remember to pass an encoding of the tree to the decompressor, followed of course by the compressed data.

There are various ways to encode the tree: pass along 256 int values, each containing the calculated weights. The decomnpressor can then use these in exactly the same way as you used to build the tree in the first place. Unfortunately 256 ints would be 1K, which is a lot to add to a compressed file.

You can analyze the weights and compress out zero values. For example, compressing a text file would result in a lot of byte values (characters, if you like) being unused and hence having a zero weight. You could devise an RLE (run length encoding) scheme that replaces runs of zero bytes in the weights table.

You could use a variable length encoding. Say you analyze the weights as you write them out. You output 2 bits before every wieght. If the bits are 00, the next weight will be 8 bits long. If the bits are 01, the next weight will be 16 bits long. If 10, the next weight will be 24 bits. If 11, a full 32 bits.

And so on. You could of course try out all these possibilities and pass along the smallest result (along with an indicator to tell the decompressor which variety was used).

Compressing and decompressing the data is the standard algorithm again. You would need to write a class that was a bit stream (to get the really nasty stuff out of the way), otherwise you're going to be writing a lot of bit manipulation code in the middle of your compression and decompression code.

Cheers, Julian
Program Manager, C#

This posting is provided "AS IS" with no warranties, and confers no rights.
GeneralRe: huffman tree algorithm Pin
Frank Olorin Rizzi24-Jul-03 4:07
Frank Olorin Rizzi24-Jul-03 4:07 
GeneralRe: huffman tree algorithm Pin
jtmtv1824-Jul-03 7:52
jtmtv1824-Jul-03 7:52 
GeneralRe: huffman tree algorithm Pin
Julian Bucknall [MSFT]24-Jul-03 8:50
Julian Bucknall [MSFT]24-Jul-03 8:50 
GeneralRe: huffman tree algorithm Pin
Frank Olorin Rizzi24-Jul-03 16:39
Frank Olorin Rizzi24-Jul-03 16:39 
GeneralMultithreaded application design question. Pin
GriffonRL23-Jul-03 11:11
GriffonRL23-Jul-03 11:11 
GeneralRe: Multithreaded application design question. Pin
wightman_michael22-Dec-09 15:40
wightman_michael22-Dec-09 15:40 
QuestionMethodInfo Invoke, bad performance? Pin
STW23-Jul-03 9:15
STW23-Jul-03 9:15 
AnswerRe: MethodInfo Invoke, bad performance? Pin
Eric Gunnerson (msft)23-Jul-03 10:02
Eric Gunnerson (msft)23-Jul-03 10:02 
GeneralRe: MethodInfo Invoke, bad performance? Pin
STW26-Jul-03 23:37
STW26-Jul-03 23:37 
GeneralRe: MethodInfo Invoke, bad performance? Pin
Eric Gunnerson (msft)27-Jul-03 5:23
Eric Gunnerson (msft)27-Jul-03 5:23 
GeneralRe: MethodInfo Invoke, bad performance? Pin
STW27-Jul-03 8:48
STW27-Jul-03 8:48 
AnswerRe: MethodInfo Invoke, bad performance? Pin
Daniel Turini23-Jul-03 11:31
Daniel Turini23-Jul-03 11:31 
GeneralRe: MethodInfo Invoke, bad performance? Pin
STW26-Jul-03 23:41
STW26-Jul-03 23:41 
GeneralAccessing Functions Pin
ppathan23-Jul-03 6:08
ppathan23-Jul-03 6:08 
GeneralRe: Accessing Functions Pin
Rocky Moore23-Jul-03 12:39
Rocky Moore23-Jul-03 12:39 
QuestionHow to birng to top an application? Pin
Ivan Fernandez23-Jul-03 3:51
Ivan Fernandez23-Jul-03 3:51 
AnswerRe: How to birng to top an application? Pin
Valeria Bogdevich23-Jul-03 9:44
Valeria Bogdevich23-Jul-03 9:44 

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.