Difference between revisions of "Aufgaben:Exercise 2.3: About the LZ78 Compression"

From LNTwww
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  
{{quiz-Header|Buchseite=Informationstheorie/Komprimierung nach Lempel, Ziv und Welch
+
{{quiz-Header|Buchseite=Information_Theory/Compression_According_to_Lempel,_Ziv_and_Welch
 
}}
 
}}
  
 
[[File:P_ID2434__Inf_A_2_3.png|right|frame|The LZ78–inventors]]
 
[[File:P_ID2434__Inf_A_2_3.png|right|frame|The LZ78–inventors]]
In contrast to entropy coding according to Huffman or Shannon, where one must know the source statistics (as precisely as possible), such restrictions do not apply to the compression methods developed by  [https://en.wikipedia.org/wiki/Abraham_Lempel Abraham Lempel]  and  [https://en.wikipedia.org/wiki/Jacob_Ziv Jacob Ziv] .  This is called ''universal source coding''.
+
In contrast to  "Entropy Coding"  according to Huffman or Shannon, where one must know the source statistics  (as precisely as possible),  such restrictions do not apply to the compression methods developed by  [https://en.wikipedia.org/wiki/Abraham_Lempel Abraham Lempel]  and  [https://en.wikipedia.org/wiki/Jacob_Ziv Jacob Ziv] .  This is called  "Universal Source Coding".
  
In this task, we consider the variant first published in 1978&nbsp; [LZ78].&nbsp;  The string &nbsp;<b>BARBARA&ndash;BAR</b> is to be encoded.
+
In this exercise, we consider the variant first published in 1978&nbsp; [LZ78].&nbsp;  The string &nbsp;<b>BARBARA&ndash;BAR</b> is to be encoded.
*The procedure LZ78 works with a global dictionary, which is initially only filled with an empty character&nbsp; $(\varepsilon)$&nbsp; under the index&nbsp; $I = 0$&nbsp;.&nbsp; This distinguishes "LZ78" from its predecessor "LZ77" (with local dictionary) and also from its successor "LZW" (dictionary is prefilled with the possible characters).
+
*The procedure&nbsp; "LZ78"&nbsp; works with a global dictionary, which is initially only filled with an empty character&nbsp; $(\varepsilon)$&nbsp; under the index&nbsp; $I = 0$.&nbsp; This distinguishes&nbsp; "LZ78"&nbsp; from its predecessor&nbsp; "LZ77"&nbsp; (with local dictionary)&nbsp; and also from its successor&nbsp; "LZW"&nbsp; (dictionary is prefilled with the possible characters).
*f a character or a word fragment (several characters) of the input string is found in the dictionary, the index&nbsp; $I_0$&nbsp; of this entry is output together with the next input character&nbsp; $Z$&nbsp;.&nbsp; In each step&nbsp; $i$&nbsp; the output is therefore: &nbsp;  $(I_0, \ Z)$.
+
*If a character or a word fragment&nbsp; (several characters)&nbsp; of the input string is found in the dictionary, the index&nbsp; $I_0$&nbsp; of this entry is output together with the next input character&nbsp; $Z$&nbsp;.&nbsp; In each step&nbsp; $i$&nbsp; the output is therefore: &nbsp;  $(I_0, \ Z)$.
*Afterwards, the new string is entered into the dictionary under the next free index&nbsp; $I_{\rm neu}$&nbsp;.  
+
*Afterwards, the new string is entered into the dictionary under the next free index&nbsp; $I_{\rm new}$.  
 
*If one considers the dictionary as a field&nbsp; $W\big[\hspace{0.05cm}I\hspace{0.05cm}\big]$&nbsp; with&nbsp; $I &ge; 0$, where each element contains a string of arbitrary length, then with the character variable&nbsp; $Z$:
 
*If one considers the dictionary as a field&nbsp; $W\big[\hspace{0.05cm}I\hspace{0.05cm}\big]$&nbsp; with&nbsp; $I &ge; 0$, where each element contains a string of arbitrary length, then with the character variable&nbsp; $Z$:
:$$W \big[\hspace{0.05cm}I_{\rm neu}\hspace{0.05cm}\big]  = W\big[\hspace{0.05cm}I_0\hspace{0.05cm}\big] + Z \hspace{0.05cm}. $$
+
:$$W \big[\hspace{0.05cm}I_{\rm new}\hspace{0.05cm}\big]  = W\big[\hspace{0.05cm}I_0\hspace{0.05cm}\big] + Z \hspace{0.05cm}. $$
 +
 
  
 
For clarification, a simple example:
 
For clarification, a simple example:
*At a given time, the dictionary is filled up to index&nbsp; $I_{\rm akt }= 20$&nbsp;.
+
*At a given time, the dictionary is filled up to index&nbsp; $I_{\rm act }= 20$.
*'''Handy'''&nbsp; is waiting to be encoded.&nbsp; In the dictionary, the &nbsp; <b>Ha</b>&nbsp; is found under index&nbsp; $I = 11$&nbsp; and the entry <b>Han</b> under index&nbsp; $I = 16$&nbsp;.
+
*'''Handy'''&nbsp; is waiting to be encoded.&nbsp; In the dictionary, &nbsp; "<b>Ha</b>"&nbsp; is found under index&nbsp; $I = 11$&nbsp; and the entry&nbsp; "<b>Han</b>"&nbsp; under index&nbsp; $I = 16$.
*Thus, the current code output is &nbsp;  $(I_0,  Z) = (16,$ <b>d</b>$)$&nbsp; and the following is entered into the dictionary as a new phrase: &nbsp; $W(21) =$ <b>Hand</b>.
+
*Thus, the current code output is &nbsp;  $(I_0,  Z) = (16,$ <b>d</b>$)$&nbsp; and the following is entered into the dictionary as a new phrase:  
*Now the string&nbsp; <b>y</b>&nbsp; is available for coding.&nbsp; If no suitable entry is found, &nbsp; $(0,$ <b>y</b>$)$&nbsp; is output and a new entry is made in the dictionary: &nbsp; $W(22) = $ $\rm &epsilon;$&nbsp; +  <b>y</b> $=$ <b>y</b> .
+
 
+
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $W(21) = $ <b>Hand</b>.
 +
*Now the string&nbsp; <b>y</b>&nbsp; is available for coding.&nbsp; If no suitable entry is found, &nbsp; $(0,$ <b>y</b>$)$&nbsp; is output and a new entry is made in the dictionary:  
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $W(22) = \rm &epsilon;$&nbsp; +  <b>y</b> $=$ <b>y</b> .
  
 
For subtask&nbsp; '''(6)'''&nbsp; you can assume the following:
 
For subtask&nbsp; '''(6)'''&nbsp; you can assume the following:
Line 29: Line 32:
  
  
 
+
Hints:
 
+
*The exercise belongs to the chapter&nbsp; [[Information_Theory/Komprimierung_nach_Lempel,_Ziv_und_Welch|Compression According to Lempel, Ziv and Welch]].
''Hints:''
+
*In particular, reference is made to the page&nbsp; [[Information_Theory/Komprimierung_nach_Lempel,_Ziv_und_Welch#The_Lempel-Ziv_variant_LZ78|The Lempel-Ziv Variant LZ78]].
*The task belongs to the chapter&nbsp; [[Information_Theory/Komprimierung_nach_Lempel,_Ziv_und_Welch|Compression According to Lempel, Ziv and Welch]].
+
*The original literature&nbsp; [LZ78]&nbsp; on this method is: <br> &nbsp; &nbsp; Ziv, J.; Lempel, A.:&nbsp; Compression of Individual Sequences via Variable-Rate Coding.&nbsp; In: IEEE Transactions on Information Theory, no. 5, vol. 24, 1978, p. 530–536.
*In particular, reference is made to the page&nbsp; [[Information_Theory/Komprimierung_nach_Lempel,_Ziv_und_Welch#The_Lempel-Ziv_variant_LZ78|The Lempel-Ziv Variant LZ78]]&nbsp;.
 
*The original literature&nbsp; [LZ78]&nbsp; on this method is: &nbsp; <br>Ziv, J.; Lempel, A.: ''Compression of Individual Sequences via Variable-Rate Coding.'' In: IEEE Transactions on Information Theory, no. 5, vol. 24, 1978, p. 530–536.
 
 
   
 
   
*&nbsp; [[Aufgaben:2.3Z_Zur_LZ77-Codierung|Exercise 2.3Z]]&nbsp; and&nbsp; [[Aufgaben:Aufgabe_2.4:_Zum_LZW-Algorithmus|Exercise 2.4]]&nbsp; deal with other&ndash;Ziv methods in a similar way.
+
*[[Aufgaben:2.3Z_Zur_LZ77-Codierung|Exercise 2.3Z]]&nbsp; and&nbsp; [[Aufgaben:Aufgabe_2.4:_Zum_LZW-Algorithmus|Exercise 2.4]]&nbsp; deal with other Lempel&ndash;Ziv methods in a similar way.
  
  
Line 42: Line 43:
  
 
<quiz display=simple>
 
<quiz display=simple>
{Welche Aussagen gelten für die Vorbelegung des LZ78&ndash;Wörterbuches?
+
{Which statements apply to the preassignment of the LZ78 dictionary?
 
|type="()"}
 
|type="()"}
+ Vorbelegt ist nur der Index&nbsp; $I = 0$&nbsp; mit dem Leerzeichen&nbsp; $(\varepsilon)$.
+
+ Only the index&nbsp; $I = 0$&nbsp; with the space&nbsp; $(\varepsilon)$ is preassigned.
- Vorbelegt sind die Indizes&nbsp; $I = 0$&nbsp; bis&nbsp; $I = 3$&nbsp; mit den vier Zeichen&nbsp; '''A''',&nbsp; '''B''',&nbsp; '''R'''&nbsp; und&nbsp; '''&ndash;''' .
+
- The indices&nbsp; $I = 0$&nbsp; to&nbsp; $I = 3$&nbsp; with the four characters&nbsp; "'''A'''",&nbsp; "'''B'''",&nbsp; '''R'''&nbsp; and&nbsp; "'''&ndash;'''" are preallocated.
  
  
{Was geschieht im Codierschritt&nbsp; $i = 1$?
+
{What happens in the coding step&nbsp; $i = 1$?
 
|type="[]"}
 
|type="[]"}
+ Die Coderausgabe lautet: &nbsp; $(0,$ <b>B</b>$)$.
+
+ The coder output is: &nbsp; $(0,$ <b>B</b>$)$.
+ Der Wörterbucheintrag lautet: &nbsp; $W(I = 1) =$ <b>B</b>.
+
+ The dictionary entry is: &nbsp; $W(I = 1) =$ <b>B</b>.
- Der Wörterbucheintrag lautet: &nbsp; $W(I = 1) =$ <b>BA</b>.
+
- The dictionary entry is: &nbsp; $W(I = 1) =$ <b>BA</b>.
  
  
{Welche Aussagen gelten für die Codierschritte&nbsp; $i = 2$&nbsp; und&nbsp; $i = 3$?
+
{Which statements are true for the coding steps&nbsp; $i = 2$&nbsp; and&nbsp; $i = 3$?
 
|type="[]"}
 
|type="[]"}
+ Für&nbsp; $i = 2$&nbsp; gilt: &nbsp; Ausgabe&nbsp; $(0,$ <b>A</b>$)$, &nbsp; Eintrag&nbsp; $W(I = 2) =$  <b>A</b>.
+
+ For&nbsp; $i = 2$&nbsp;, the following is true: &nbsp; Output&nbsp; $(0,$ <b>A</b>$)$, &nbsp; entry&nbsp; $W(I = 2) =$  <b>A</b>.
+ Für&nbsp; $i = 3$&nbsp; gilt: &nbsp; Ausgabe&nbsp; $(0,$ <b>R</b>$)$, &nbsp; Eintrag&nbsp; $W(I = 3) =$ <b>R</b>.
+
+ For&nbsp; $i = 3$&nbsp;, the following is true: &nbsp; Output&nbsp; $(0,$ <b>R</b>$)$, &nbsp; entry&nbsp; $W(I = 3) =$ <b>R</b>.
  
  
{Welche Aussagen gelten für den Codierschritt&nbsp; $i = 4$?
+
{Which statements are true for the coding step&nbsp; $i = 4$?
 
|type="[]"}
 
|type="[]"}
- Bei Schritt&nbsp; $i = 4$&nbsp; wird&nbsp; <b>BAR</b>&nbsp; gemeinsam codiert.
+
- At step&nbsp; $i = 4$&nbsp; &nbsp; <b>BAR</b>&nbsp; is coded together.
+ Bei Schritt&nbsp; $i = 4$&nbsp; wird&nbsp; <b>BA</b>&nbsp; gemeinsam codiert.
+
+ At step&nbsp; $i = 4$&nbsp; &nbsp; <b>BA</b>&nbsp; is coded together.
- Die Coderausgabe lautet: &nbsp; $(2,$ <b>AR</b>$)$.
+
- The coder output is: &nbsp; $(2,$ <b>AR</b>$)$.
+ Die Coderausgabe lautet: &nbsp; $(1,$ <b>A</b>$)$.
+
+ The coder output is: &nbsp; $(1,$ <b>A</b>$)$.
  
  
{Vervollständigen Sie die LZ78&ndash;Codierung.&nbsp; Nach welchem Codierschritt&nbsp; $i_{\rm Ende}$&nbsp; ist&nbsp; <b>BARBARA&ndash;BAR</b>&nbsp; vollständig codiert?
+
{Complete the LZ78 coding.&nbsp; After which coding step&nbsp; $i_{\rm end}$&nbsp; is&nbsp; "<b>BARBARA&ndash;BAR</b>"&nbsp; completely coded?
 
|type="{}"}
 
|type="{}"}
$i_{\rm Ende} \ = \ $ { 7 3% }
+
$i_{\rm end} \ = \ $ { 7 3% }
  
  
{Wieviele Binärzeichen benötigt man, um&nbsp; <b>BARBARA&ndash;BAR</b>&nbsp; zu codieren?&nbsp; Beachten Sie die Hinweise auf der Angabenseite.
+
{How many binary characters are needed to code&nbsp; "<b>BARBARA&ndash;BAR"</b>&nbsp;?&nbsp; Follow the instructions on the information page.
 
|type="{}"}
 
|type="{}"}
$\text{ohne Codierung:  }\ N \ = \ $ { 22 3% } $\ \rm Bit$
+
$\text{without coding:  }\ N \ = \ $ { 22 3% } $\ \rm bits$
$\text{mit LZ78-Codierung:  }\ N \ = \ $ { 35 3% } $\ \rm Bit$
+
$\text{with LZ78 coding:  }\ N \ = \ $ { 35 3% } $\ \rm bits$
  
  
Line 83: Line 84:
 
</quiz>
 
</quiz>
  
===Musterlösung===
+
===Solution===
 
{{ML-Kopf}}
 
{{ML-Kopf}}
'''(1)'''&nbsp; Zutreffend für den LZ78&ndash;Algorithmus ist <u>Aussage 1</u>:  
+
'''(1)'''&nbsp; <u>Statement 1</u> applies to the LZ78 algorithm:
*Die Vorbelegung gemäß Aussage 2 gilt dagegen für den LZW&ndash;Algorithmus, der 1983 gemeinsam mit Terry Welch veröffentlicht wurde.
+
*In contrast, the preassignment according to statement 2 is true for the LZW algorithm, which was published in 1983 together with Terry Welch.
 +
 
  
  
  
'''(2)'''&nbsp; $\rm &epsilon;$&nbsp; bezeichnet das leere Zeichen.&nbsp;  
+
'''(2)'''&nbsp; $\rm &epsilon;$&nbsp; denotes the empty character.&nbsp;  
*Da&nbsp; $\rm &epsilon;$ + <b>B</b> = <b>B</b>&nbsp; ergibt, sind die <u>Aussagen 1 und 2</u> richtig.  
+
*Since&nbsp; $\rm &epsilon;$ + <b>B</b> = <b>B</b> &nbsp; &rArr; &nbsp; <u>statements 1 and 2</u> are correct.  
*Aussage 3 trifft wieder nur für die LZW&ndash;Komprimierung zu.
+
*Statement 3 is again only true for LZW compression.
  
  
  
'''(3)'''&nbsp; Hier treffen <u>beide Aussagen</u> zu.
+
'''(3)'''&nbsp; Here <u>both statements</u> are true.
  
  
  
'''(4)'''&nbsp; Richtig sind die <u>Aussagen 2 und 4</u>:   
+
'''(4)'''&nbsp; <u>Statements 2 and 4</u> are correct:   
*Im Wörterbuch wird unter dem Index&nbsp; $I = 1$&nbsp; das Zeichen&nbsp; <b>B</b>&nbsp; gefunden.
+
*In the dictionary, character&nbsp; <b>B</b>&nbsp; is found under index &nbsp; $I = 1$.
*Das nächste Zeichen&nbsp; <b>A</b>&nbsp; der Eingangsfolge wird angehängt: &nbsp; <b>(1, A)</b>.  
+
*The next character&nbsp; <b>A</b>&nbsp; of the input sequence is appended: &nbsp; <b>(1, A)</b>.  
*Die Aussage 3 kann schon deshalb nicht stimmen, da&nbsp; $Z$&nbsp; nur ein Zeichen sein kann und keine Zeichenfolge.
+
*Statement 3 cannot be correct because&nbsp; $Z$&nbsp; can only be a character and not a character sequence.
  
  
  
[[File:EN_Inf_A_2_3f.png|right|frame|LZ78–Codierung von&nbsp; <b>BARBARA–BAR</b>]]
+
[[File:EN_Inf_A_2_3f.png|right|frame|LZ78 coding of&nbsp; "<b>BARBARA–BAR</b>"]]
'''(5)'''&nbsp; Der gesamte Codiervorgang ist in einer Tabelle zusammengefasst. Man erkennt:
+
'''(5)'''&nbsp; The entire coding process is summarised in the table on the right.&nbsp; One can see:
* Zu jedem Zeitpunkt&nbsp; $i$&nbsp; wird die bearbeitete Zeichenfolge in das Wörterbuch eingetragen.
+
* At each time&nbsp; $i$,&nbsp; the edited string is entered into the dictionary.
* Zum Zeitpunkt&nbsp; $\underline{i=7}$&nbsp; ist der Codiervorgang abgeschlossen.
+
* At time&nbsp; $\underline{i=7}$&nbsp; the coding process is completed.
  
  
  
'''(6)'''&nbsp; Stellt man alle Indizes mit drei Bit dar und die vier Zeichen (Character) mit je zwei Bit, so kommt man zu folgenden Ergebnissen:
+
'''(6)'''&nbsp; If we represent all indices with three bits and the four characters with two bits each, we get the following results:
* ohne Codierung: &nbsp; $N = 11 \cdot 2 \hspace{0.15cm}\underline {= 22 \, \rm Bit}$,
+
* Without coding: &nbsp; $N = 11 \cdot 2 \hspace{0.15cm}\underline {= 22 \, \rm bits}$,
* mit LZ78&ndash;Codierung: &nbsp; $N = 7 \cdot (3+2) \hspace{0.15cm}\underline {= 35 \, \rm Bit}$.
+
* with LZ78 coding: &nbsp; $N = 7 \cdot (3+2) \hspace{0.15cm}\underline {= 35 \, \rm bits}$.
  
  
Daran erkennt man:
+
You can see from this:
* Eine jede LZ&ndash;Komprimierung macht erst bei einer größeren Datei Sinn, auch dann, wenn man glaubt, dass ein Text wie&nbsp; <b>BARBARA&ndash;BAR</b>&nbsp; dem LZ78&ndash;Algorithmus entgegenkommt.
+
* Any LZ compression only makes sense with a larger file, even if one believes that a text like&nbsp; "<b>BARBARA&ndash;BAR</b>"&nbsp; accommodates the LZ78 algorithm.
* Mit variabler Bitanzahl für den Index entsprechend der Aufgabe 2.4 würde sich für dieses LZ78-Beispiel ergeben:
+
* With variable number of bits for the index according to Exercise 2.4, the result for this LZ78 example would be:
:$$N = 1 \cdot 3 + 2 \cdot 4 + 4 \cdot 5 = 31 \,{\rm Bit}\hspace{0.05cm}.$$
+
:$$N = 1 \cdot 3 + 2 \cdot 4 + 4 \cdot 5 = 31 \,{\rm bits}\hspace{0.05cm}.$$
 
{{ML-Fuß}}
 
{{ML-Fuß}}
  
Line 130: Line 132:
  
  
[[Category:Information Theory: Exercises|^2.2 Verfahren von Lempel, Ziv, Welch^]]
+
[[Category:Information Theory: Exercises|^2.2 Lempel-Ziv-Welch Compression^]]

Latest revision as of 13:10, 10 August 2021

The LZ78–inventors

In contrast to  "Entropy Coding"  according to Huffman or Shannon, where one must know the source statistics  (as precisely as possible),  such restrictions do not apply to the compression methods developed by  Abraham Lempel  and  Jacob Ziv .  This is called  "Universal Source Coding".

In this exercise, we consider the variant first published in 1978  [LZ78].  The string  BARBARA–BAR is to be encoded.

  • The procedure  "LZ78"  works with a global dictionary, which is initially only filled with an empty character  $(\varepsilon)$  under the index  $I = 0$.  This distinguishes  "LZ78"  from its predecessor  "LZ77"  (with local dictionary)  and also from its successor  "LZW"  (dictionary is prefilled with the possible characters).
  • If a character or a word fragment  (several characters)  of the input string is found in the dictionary, the index  $I_0$  of this entry is output together with the next input character  $Z$ .  In each step  $i$  the output is therefore:   $(I_0, \ Z)$.
  • Afterwards, the new string is entered into the dictionary under the next free index  $I_{\rm new}$.
  • If one considers the dictionary as a field  $W\big[\hspace{0.05cm}I\hspace{0.05cm}\big]$  with  $I ≥ 0$, where each element contains a string of arbitrary length, then with the character variable  $Z$:
$$W \big[\hspace{0.05cm}I_{\rm new}\hspace{0.05cm}\big] = W\big[\hspace{0.05cm}I_0\hspace{0.05cm}\big] + Z \hspace{0.05cm}. $$


For clarification, a simple example:

  • At a given time, the dictionary is filled up to index  $I_{\rm act }= 20$.
  • Handy  is waiting to be encoded.  In the dictionary,   "Ha"  is found under index  $I = 11$  and the entry  "Han"  under index  $I = 16$.
  • Thus, the current code output is   $(I_0, Z) = (16,$ d$)$  and the following is entered into the dictionary as a new phrase:

            $W(21) = $ Hand.

  • Now the string  y  is available for coding.  If no suitable entry is found,   $(0,$ y$)$  is output and a new entry is made in the dictionary:

            $W(22) = \rm ε$  + y $=$ y .

For subtask  (6)  you can assume the following:

  • The decimal number  $I$  (index) is represented in binary by three bits.
  • The character  $Z ∈ \{$ABR$ \}$  is binary coded by two bits each.




Hints:

  • The exercise belongs to the chapter  Compression According to Lempel, Ziv and Welch.
  • In particular, reference is made to the page  The Lempel-Ziv Variant LZ78.
  • The original literature  [LZ78]  on this method is:
        Ziv, J.; Lempel, A.:  Compression of Individual Sequences via Variable-Rate Coding.  In: IEEE Transactions on Information Theory, no. 5, vol. 24, 1978, p. 530–536.


Questions

1

Which statements apply to the preassignment of the LZ78 dictionary?

Only the index  $I = 0$  with the space  $(\varepsilon)$ is preassigned.
The indices  $I = 0$  to  $I = 3$  with the four characters  "A",  "B",  R  and  "" are preallocated.

2

What happens in the coding step  $i = 1$?

The coder output is:   $(0,$ B$)$.
The dictionary entry is:   $W(I = 1) =$ B.
The dictionary entry is:   $W(I = 1) =$ BA.

3

Which statements are true for the coding steps  $i = 2$  and  $i = 3$?

For  $i = 2$ , the following is true:   Output  $(0,$ A$)$,   entry  $W(I = 2) =$ A.
For  $i = 3$ , the following is true:   Output  $(0,$ R$)$,   entry  $W(I = 3) =$ R.

4

Which statements are true for the coding step  $i = 4$?

At step  $i = 4$    BAR  is coded together.
At step  $i = 4$    BA  is coded together.
The coder output is:   $(2,$ AR$)$.
The coder output is:   $(1,$ A$)$.

5

Complete the LZ78 coding.  After which coding step  $i_{\rm end}$  is  "BARBARA–BAR"  completely coded?

$i_{\rm end} \ = \ $

6

How many binary characters are needed to code  "BARBARA–BAR" ?  Follow the instructions on the information page.

$\text{without coding: }\ N \ = \ $

$\ \rm bits$
$\text{with LZ78 coding: }\ N \ = \ $

$\ \rm bits$


Solution

(1)  Statement 1 applies to the LZ78 algorithm:

  • In contrast, the preassignment according to statement 2 is true for the LZW algorithm, which was published in 1983 together with Terry Welch.



(2)  $\rm ε$  denotes the empty character. 

  • Since  $\rm ε$ + B = B   ⇒   statements 1 and 2 are correct.
  • Statement 3 is again only true for LZW compression.


(3)  Here both statements are true.


(4)  Statements 2 and 4 are correct:

  • In the dictionary, character  B  is found under index   $I = 1$.
  • The next character  A  of the input sequence is appended:   (1, A).
  • Statement 3 cannot be correct because  $Z$  can only be a character and not a character sequence.


LZ78 coding of  "BARBARA–BAR"

(5)  The entire coding process is summarised in the table on the right.  One can see:

  • At each time  $i$,  the edited string is entered into the dictionary.
  • At time  $\underline{i=7}$  the coding process is completed.


(6)  If we represent all indices with three bits and the four characters with two bits each, we get the following results:

  • Without coding:   $N = 11 \cdot 2 \hspace{0.15cm}\underline {= 22 \, \rm bits}$,
  • with LZ78 coding:   $N = 7 \cdot (3+2) \hspace{0.15cm}\underline {= 35 \, \rm bits}$.


You can see from this:

  • Any LZ compression only makes sense with a larger file, even if one believes that a text like  "BARBARA–BAR"  accommodates the LZ78 algorithm.
  • With variable number of bits for the index according to Exercise 2.4, the result for this LZ78 example would be:
$$N = 1 \cdot 3 + 2 \cdot 4 + 4 \cdot 5 = 31 \,{\rm bits}\hspace{0.05cm}.$$