0% found this document useful (0 votes)
19 views10 pages

DC Last Exam Notes

Uploaded by

needforyou32
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views10 pages

DC Last Exam Notes

Uploaded by

needforyou32
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Q.

Write the Difference between Lossy compression


and Lossless compression.
UNIT 03

Q. List out various applications of dictionary coding.


1. Text Compression

 Applications: ZIP, GZIP, and other file compression utilities use dictionary
coding to compress text documents, code files, and configuration files.

 Benefit: By storing repeated phrases and words in a dictionary, dictionary


coding reduces the size of text files without losing information, making it ideal
for compressing documents, source code, and logs.

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.

 Benefit: Audio files, especially those with repetitive patterns or low


complexity, can be efficiently compressed using dictionary-based methods,
which help reduce file sizes while preserving sound quality.

4. Video Compression

 Applications: Dictionary-based coding techniques are used in MPEG-4, H.264,


and HEVC (High-Efficiency Video Coding) as part of their compression
algorithms.
 Benefit: Repetitive patterns within frames (like backgrounds or common
objects) are compressed using dictionary coding, which reduces data
redundancy and lowers the overall file size.

Q. List out application of Image Compression


i. GIF (Graphics Interchange Format)

 Compression Method: GIF uses LZW compression, which is a lossless


dictionary-based coding method. It compresses data by identifying repeating
patterns and assigning shorter codes to frequently occurring sequences.

 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 Lossless Compression: Ensures no loss of quality, making it suitable


for graphics that require clear edges and sharp detail.

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.

ii. PNG (Portable Network Graphics)

 Compression Method: PNG uses Deflate compression, a lossless algorithm


combining LZ77 (a dictionary-based method) and Huffman coding to
compress image data without any quality loss.

 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.

Q. Explain encoding and decoding technique use in


LZ78.
 LZ78 Encoding Technique

1. Initialization:

o Start with an empty dictionary and an initial code of 1 for new entries.

2. Reading Input:

o Read the input data one symbol (or character) at a time.

3. Pattern Matching:

o For each symbol, check if the current sequence (previous symbols +


current symbol) exists in the dictionary:

 If found: Extend the sequence with the next symbol in the input
and check again.

 If not found: The current sequence (without the last symbol) is


already in the dictionary.

4. Dictionary Update and Code Output:

o When a new sequence is encountered (one that’s not in the dictionary):

 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:

o Continue the process until all input data is encoded.

Example of LZ78 Encoding


Consider the input string: ABABABA

 Dictionary:

o Initially empty, so add new patterns as they appear.

 Encoding Process:

o A: Not in dictionary, so output (0, A) and add A with code 1.

o B: Not in dictionary, so output (0, B) and add B with code 2.

o AB: Not in dictionary, so output (1, B) and add AB with code 3.

o ABA: Not in dictionary, so output (3, A) and add ABA with code 4.

o Encoded Output: (0, A), (0, B), (1, B), (3, A)

 LZ78 Decoding Technique

1. Initialization:

o Start with an empty dictionary.

2. Reading Encoded Data:

o Read each pair (index, symbol) from the encoded data.

3. Pattern Reconstruction:

o For each pair:

 If the index is 0: The symbol is a new entry, so add it directly to


the dictionary.

 If the index is not 0: Retrieve the pattern from the dictionary


using the index, append the symbol, and add this new sequence
to the dictionary.

4. Output Construction:

o Output the decoded sequence as each pattern is reconstructed.

5. Repeat:

o Continue the process until the entire encoded sequence is decoded.


Example of LZ78 Decoding (using encoded data from the example)

 Encoded Data: (0, A), (0, B), (1, B), (3, A)

 Decoding Process:

o (0, A): Output A, add A to the dictionary.

o (0, B): Output B, add B to the dictionary.

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.

 Decoded Output: ABABABA

Q. Discuss LZ77 algorithm and justify – the size of


window affects the performance of LZ77 algorithm.
List out advantage and disadvantage of LZ77.
LZ77 is a dictionary-based, lossless compression algorithm. The algorithm works by
finding and encoding repeating patterns within a sliding window of data, making it
efficient for compressing files with redundant information.

How LZ77 Works

1. Sliding Window: LZ77 uses a sliding window that moves over the data. This
window is divided into two parts:

o Search Buffer: Contains previously processed data.

o Look-Ahead Buffer: Contains the upcoming data to be processed.

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 If a match is found, it is represented by a triplet (offset, length, next


symbol):
 Offset: Distance back from the current position to the start of the
match.

 Length: Length of the matching sequence.

 Next Symbol: The next symbol following the match.

3. Sliding the Window:

o After encoding, the window slides forward, and the process continues
until the entire input is compressed.

Impact of Window Size on LZ77 Performance

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:

o Pros: Allows for longer lookbacks to find repeated patterns, improving


the chance of finding longer matches. This results in better
compression ratios for files with recurring patterns spread over long
distances.

o Cons: Increases memory usage and computational complexity, as the


algorithm must search a larger buffer, which can slow down
compression.

 Smaller Window:

o Pros: Reduces memory usage and computational complexity, making


the algorithm faster, especially for smaller files or real-time
applications.

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.

Thus, the window size is a trade-off between compression efficiency and


computational resources. Larger windows work well for compressing files with long-
term redundancies, while smaller windows are more efficient for short, localized
patterns or lower memory environments.
Advantages of LZ77

1. Efficient with Redundant Data: LZ77 achieves good compression on files


with repeated patterns, such as text and binary data.

2. Adaptability: The algorithm dynamically adjusts to different patterns without


needing a predefined dictionary.

3. Foundational: LZ77 is the basis for many advanced algorithms (e.g., DEFLATE
used in ZIP and PNG files).

Disadvantages of LZ77

1. Limited by Window Size: LZ77’s performance depends on the window size,


which restricts the maximum match length.

2. Inefficiency with Non-repetitive Data: For data with little to no redundancy,


LZ77 provides minimal compression.

3. Potential Overhead: The algorithm’s triplet representation can add overhead


for small files, where the encoded data could be larger than the original.
Q. Differentiate Uniform Quantization and Non-
Uniform Quantization.

You might also like