0

最近から、データ圧縮のためのLZW アルゴリズムを研究しています。エンコード アルゴリズムは理解できましたが、エンコードされたデータを元の形式に変換するデコード アルゴリズムについては理解できません。

以下は、ここから取得したデコーダーの擬似コードです。

string entry;
char ch;
int prevcode, currcode;
...

prevcode = read in a code;
decode/output prevcode;
while (there is still data to read)
{
  currcode = read in a code;
  entry = translation of currcode from dictionary;
  output entry;
  ch = first char of entry;
  add ((translation of prevcode)+ch) to dictionary;
  prevcode = currcode;
}

このコードの段階的な説明を探しています。

編集:私が理解していないのはこれです:なぜ3つの異なる文字列、つまりentryprevcode、およびcurrcode があるのですか? 私の意見では、1 つはエンコードされた文字列で、2 番目は作成される出力文字列です。では、そこで 3 番目の文字列は何をしているのでしょうか。

次に、コードの最後から 2 行目にある(prevcode の翻訳)+chの目的がよくわかりません。

ありがとう。

4

1 に答える 1