take this algorithms and hope it helps u : :)
The LZW compression algorithm:
STRING = get input character
WHILE there are still input characters DO
CHARACTER = get input character
IF STRING+CHARACTER is in the string table then
STRING = STRING+character
ELSE
output the code for STRING
add STRING+CHARACTER to the string table
STRING = CHARACTER
END of IF
END of WHILE
output the code for STRING
and this is the decompression algorithm.
Read OLD_CODE
output OLD_CODE
WHILE there are still input characters DO
Read NEW_CODE
STRING = get translation of NEW_CODE
output STRING
CHARACTER = first character in STRING
add OLD_CODE + CHARACTER to the translation table
OLD_CODE = NEW_CODE
END of WHILE
and this is another reference
Hope it helps you
Best Regards,
Basem Moghram