Press Next and watch the answer-script table fill in one row at a time, exactly as you write it in the exam. Then try Yes / No quiz, and finally Fill the table: you type every cell yourself and the page marks it like an examiner.
The whole method is one question, asked again and again
Before you start (write this line in the paper): the image is 8-bit, so dictionary locations 0–255 already hold every gray level 0–255. New entries start at 256. A 9-bit code gives 512 locations. Read the pixels left to right, top to bottom. The Currently Recognized Sequence (CRS) starts empty.
Take the CRS, stick the next pixel P on the end. Is “CRS-P” already in the dictionary?
YES
Write nothing in Encoded Output.
CRS grows: CRS = CRS-P.
NO
Output the code of CRS (a single pixel's code is the pixel itself).
Add “CRS-P” at the next free location (256, 257, …).
CRS restarts as just P.
When the pixels run out: output the code of the last CRS. Done.
Trainer
Mode
Image
CRS (what you are holding)P (pixel being processed)
Same pixels in reading order
New dictionary entries
Answer script
Currently recognized sequence
Pixel being processed
Encoded output
Dictionary location (code word)
Dictionary entry
Things that cost marks
The first column shows the CRS before P is added. On a YES row it then grows; on a NO row it restarts as P.
Only NO rows have an output, a location and an entry. YES rows have just the first two columns.
A single pixel (39, 126…) is always in the dictionary, so the very first row is always a YES with an empty CRS.
When the CRS is a sequence like 39-39, its code is its location (256), not the pixels.
Don't forget the last row: no pixel left, output the code of the final CRS.
Compression ratio: original = pixels × 8 bits; encoded = number of outputs × 9 bits. CR = original / encoded.
LZW removes spatial (inter-pixel) redundancy: repeated pixel patterns become one code. It needs no probabilities and is used in GIF, TIFF and PDF.