is found, then last matching index is set to the index of the matching entry, nothing is output, and last matching index is left representing the input so far. Input is processed until a match is not found. Then a new dictionary entry is created, , and the algorithm outputs last matching index, followed by token, then resets last matching index = 0 and increments next available index. As an example consider the sequence of tokens which would assemble the dictionary; and the output sequence of the compressed data would be . Note that the last A is not represented yet as the algorithm cannot know what comes next. In practice an EOF marker is added to the input - for example. Note also that in this case the output is longer than the original input but compression ratio improves considerably as the dictionary grows, and in binary the indexes need not be represented by any more than the minimum number of bits. Decompression consists of rebuilding the dictionary from the compressed sequence. From the sequence the first entry is always the terminator , and the first from the sequence would be . The is added to the output. The second pair from the input is and results in entry number 2 in the dictionary, . The token "B" is output, preceded by the sequence represented by dictionary entry 1. Entry 1 is an 'A' (followed by "entry 0" - nothing) so is added to the output. Next is added to the dictionary as the next entry, , and B (preceded by nothing) is added to the output. Finally a dictionary entry for is created and is output resulting in or removing the spaces and EOF marker. LZW LZW is an LZ78-based algorithm that uses a dictionary pre-initialized with all possible characters (symbols) or emulation of a pre-initialized dictionary. The main improvement of LZW is that when a match is not found, the current input stream character is assumed to be the first character of an existing string in the dictionary (since the dictionary is initialized with all possible characters), so only the last matching index is output (which may be the pre-initialized dictionary index corresponding to the previous (or the initial) input character). Refer to the LZW article for implementation details. BTLZ is an LZ78-based algorithm that was developed for use in real-time communications systems (originally modems) and standardized