一月
02
2012

LZW compression & decompression pseudocode

期末考記錄用
參考自此但我覺得需要修改

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
}

無迴響 »

RSS feed for comments on this post. TrackBack URL


Leave a Reply

Powered by WordPress | Theme: Aeros 2.0 by TheBuckmaker.com