DC Last Exam Notes
DC Last Exam Notes
Applications: ZIP, GZIP, and other file compression utilities use dictionary
coding to compress text documents, code files, and configuration files.
2. Image Compression
Applications: GIF, TIFF, and some PDF formats use dictionary coding for
lossless image compression.
Benefit: For images with repeated patterns (like icons, logos, or drawings),
dictionary-based methods like LZW compress image data without degrading
quality. This is particularly useful in applications like web graphics (GIF) where
file size and quality matter.
3. Audio Compression
Applications: FLAC, MPEG-4 ALS (Audio Lossless Coding), and other lossless
audio formats use dictionary coding techniques as part of their compression
process.
4. Video Compression
Application: GIF is widely used for simple web graphics, such as logos, icons,
and animations, because it supports up to 256 colors, transparency, and
animation.
Advantages:
o Animation Support: GIF can store multiple frames within a single file,
enabling short, looping animations commonly used in social media and
web applications.
Limitations:
o Limited color palette (8-bit, 256 colors max), making it less suitable for
high-quality images or complex photographs.
Application: PNG is ideal for web images that need high quality, such as
logos, icons, and transparent images. It supports 24-bit color (16 million
colors) and an alpha channel for transparency.
Advantages:
o High-Quality Graphics: PNG supports true-color (24-bit) images,
making it ideal for complex, high-quality images without quality
degradation.
1. Initialization:
o Start with an empty dictionary and an initial code of 1 for new entries.
2. Reading Input:
3. Pattern Matching:
If found: Extend the sequence with the next symbol in the input
and check again.
Output the dictionary index for the last known sequence and
the new symbol that extended it.
Add the new sequence to the dictionary with the next available
code.
5. Repeat:
Dictionary:
Encoding Process:
o ABA: Not in dictionary, so output (3, A) and add ABA with code 4.
1. Initialization:
3. Pattern Reconstruction:
4. Output Construction:
5. Repeat:
Decoding Process:
o (1, B): Look up 1 (which is A), add B to get AB, and add AB to the
dictionary.
(3, A): Look up 3 (which is AB), add A to get ABA, and add ABA to the dictionary.
1. Sliding Window: LZ77 uses a sliding window that moves over the data. This
window is divided into two parts:
2. Pattern Matching:
o For each position in the look-ahead buffer, the algorithm searches for
the longest matching sequence in the search buffer.
o After encoding, the window slides forward, and the process continues
until the entire input is compressed.
The size of the sliding window (search buffer) significantly affects the performance
of the LZ77 algorithm in terms of compression ratio and computational efficiency:
Larger Window:
Smaller Window:
o Cons: Limits the search range, potentially missing some matches. This
can result in lower compression ratios, particularly for data with
patterns that appear infrequently or are widely spaced.
3. Foundational: LZ77 is the basis for many advanced algorithms (e.g., DEFLATE
used in ZIP and PNG files).
Disadvantages of LZ77