LZW and RLE Text Compression
with Two-Step Pipeline Analysis
Table of Contents
1. Task1
- Randomly generate a file of 10,000 characters using the specified alphabet (uppercase and lowercase letters). Encode the text information using the algorithm specified in the task. Determine the encoding cost. Decode the information, determine the compression ratio. Programmatically verify that the decoding was performed correctly.
- Encode the information using the RLE algorithm. Decode the information, determine the compression ratio. Programmatically verify that the decoding occurred correctly.
- Similarly to point 2, encode the information using two-step encoding (RLE + variant algorithm and algorithm option + RLE). Show which method is more effective.
Alphabet: { й, ё, п, в, о, д, space, 0-9, &, . }
Algorithm: LZW
2. Documentation
Sadly, there is no report for this lab.
3. Showcase
Generating data...
Generated: 1480044 bytes
LZW encode/decode...
Coding cost: 3.05
Encoded into: 588393 bytes
Compression coefficent (out/in): 0.39
Files ./out/data.txt and ./out/data-enc-lzw-dec-lzw.txt are identical
RLE encode/decode...
Encoded into: 1087997 bytes
Compression coefficent (out/in): 0.73
Files ./out/data.txt and ./out/data-enc-rle-dec-rle.txt are identical
LZW-RLE encode/decode...
Encoded into: 1001594 bytes
Compression coefficent (out/in): 0.67
Files ./out/data-enc-lzw.bin and ./out/data-enc-lzw-brle-dec-brle.bin are identical
RLE-LZW encode/decode...
Encoded into: 609561 bytes
Compression coefficent (out/in): 0.41
Files ./out/data-enc-rle.txt and ./out/data-enc-rle-lzw-dec-lzw.txt are identical
LZW encoding is the most efficient
4. Unlicense
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to https://unlicense.org/
Footnotes:
Original text:
- Случайно сгенерировать файл в 10 тысяч символов, используя указанный алфавит (заглавные и строчные буквы). Закодировать текстовую информацию, используя указанный в задании алгоритм. Определить цену кодирования. Декодировать информацию, определить коэффициент сжатия. Программно проверить, что декодирование произошло верно.
- Закодировать информацию алгоритмом RLE. Декодировать информацию, определить коэффициент сжатия. Программно проверить, что декодирование произошло верно.
- Аналогично пункту 2 закодировать информацию, применив двухступенчатое кодирование (RLE + алгоритм варианта и алгоритм варианта + RLE). Показать, какой из способов более эффективный.
Алфавит: { й, ё, п, в, о, д, пробел, 0-9, &, . }
Алгоритм: LZW
Created: 2026-11-07 Sat 05:37
