期末考記錄用
參考自此但我覺得需要修改
LZW compression
string = NULL;
while character = next input character{
if string+character is in table {
string = string + character
} else {
output code of string
add string+character to table
string = character
}
}
LZW decompression
while code = next input code {
if code is new code {
string = translated code
output string
// string(0) is the first character of string
add prevString+string(0) to table
} else {
add to table for known code sequence
string = translated code
output string
}
prevString = string
}
