write a simple compression program inc that can be used to compress the input file,given that all characters are ascii letters from a-z or A-Z or contains space and dots(.).
please reply ASAP..
write a simple compression program inc that can be used to compress the input file,given that all characters are ascii letters from a-z or A-Z or contains space and dots(.).
please reply ASAP..
A simple compression algorithm is RLE encoding.
http://en.wikipedia.org/wiki/Run-length_encoding
RLE works poorly on written text, as most of the time, there is no more than two letters in a row that are the same. Since RLE builds on storing count and what to repeat, it doesn't work well when there aren't long sequences of items that are the same.
A better method would be for example
- Huffman coding.
- LZW
- ZIP
- Bytepair
All of these are based on "replacing the existing item with a shorter one". Bytepair can probably [for many instances] also be modified such that it is "text only" by using unusual/unused printable characters for the replacement.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.