Bölüm 5 · Simülatör

String Compression Algorithms

← Bölüm 5

Press Prepare to start.

Compressed Output

Ratio: —
Not available yet.

Runs

Runs will appear here.

    String Compression Algorithms

    Visualize Run Length Encoding (RLE) and Lempel-Ziv-Welch (LZW) step by step.

    How to use

    • Type an input text (up to 24 characters) and choose an algorithm. Changing the algorithm loads a matching example.
    • Prepare generates all steps; Next Step advances one step, Auto Run plays the rest, Reset clears the run.
    • Yellow cell: the character being processed. Green cells: the current run (RLE).
    • The bottom line keeps the last few steps; the ratio appears when the run is complete.

    Run Length Encoding (RLE)

    RLE replaces each run of repeated symbols with a count-symbol pair, for example AAAAABB → 5A2B. It works well when the input contains long runs and can make the output longer when it does not.

    Lempel-Ziv-Welch (LZW)

    LZW starts with a dictionary of the single characters of the input. While scanning, it extends the current sequence w with the next character c. If wc is already in the dictionary, w = wc; otherwise it outputs the code of w, adds wc as a new code and restarts with w = c. The dictionary grows as new sequences appear.

    In the Dictionary panel the green entry is the current w, the yellow entry is the code added in this step.

    Compression ratio

    Ratio = compressed units / original units. For RLE the units are the characters of the output tokens; for LZW they are the emitted codes.

    Complexity

    AlgorithmTimeExtra space
    RLEO(n)O(1) besides output
    LZWO(n) expected (hash dictionary)O(n) dictionary