Skip to main content
. 2019 Jul 19;19(14):3190. doi: 10.3390/s19143190
Algorithm 2 LZW Pseudocode
  initialize Dictionary[0-255] = first 256 ASCII codes
  STRING ← get input symbol
  while there are still input symbols do
    SYMBOL ← get input symbol
    if (STRING+SYMBOL is in Dictonary) then
      STRING = STRING+SYMBOL
    else
      output the code for STRING
      add STRING+SYMBOL to Dictionary
      STRING = SYMBOL
    end if
  end while
  output the code for STRING