There is a way that is the right way

Report a typo

Sort actions of the LZW algorithm in the right order based on the most common case.

Put the items in the correct order
Go to the next unreplaced input in the input stream and repeat the second step.
Replace the current input with the dictionary index.
Find the longest sequence in the dictionary that matches the input.
Take replaced input together with the next symbol and add them to the next row in the dictionary.
Prepare the dictionary.
___

Create a free account to access the full topic