Data Compression

Help Questions

AP Computer Science Principles › Data Compression

Questions 1 - 10
1

Read the passage. A media company publishes articles, photos, and videos and uses different compression methods depending on content. Compression reduces the number of bits needed by encoding patterns more efficiently, helping files download faster and cost less to store. Lossless compression preserves exact data and is favored for text, where accuracy matters, while lossy compression discards some information to achieve smaller files and is common for images and video. Huffman coding and LZW are lossless techniques often used for text or general data, while JPEG is a popular lossy format for still images. MPEG is widely used for video compression, often balancing quality against file size. Selecting the right method depends on whether perfect fidelity or smaller size is the priority.

Based on the text, how does Huffman coding differ from JPEG compression?

Huffman is lossless for symbols; JPEG is lossy for images.

Huffman increases size; JPEG always eliminates artifacts entirely.

Huffman discards details; JPEG preserves every original bit.

Huffman is a video standard; JPEG compresses text files.

Explanation

This question tests AP Computer Science Principles skills in understanding data compression, specifically comparing the fundamental differences between Huffman coding and JPEG compression. Data compression uses different methods for different content types, with Huffman coding being a lossless technique for text and symbols, while JPEG is a lossy format designed specifically for images. In the provided passage, Huffman coding is described as a 'lossless technique often used for text,' while JPEG is identified as 'a popular lossy format for still images.' Choice A is correct because it accurately captures this fundamental distinction: Huffman is lossless and works with symbols/text, while JPEG is lossy and designed for images, as explicitly stated in the passage. Choice C is incorrect because it reverses their characteristics - Huffman preserves data (lossless) while JPEG discards details (lossy). To help students: Create comparison tables showing compression methods grouped by lossless vs. lossy and their typical applications. Emphasize that the choice of compression method depends on both the content type and whether perfect accuracy is required.

2

Which of the following is guaranteed when using a lossless data compression algorithm?

The time required to compress the file will be less than the time required to decompress it.

The original data can be restored in its entirety from the compressed data without any loss.

The compressed file can be used by applications without needing to be decompressed first.

The compressed file will always be at least 50 percent smaller than the original file.

Explanation

The defining feature and guarantee of any lossless compression algorithm is perfect fidelity. The decompression process is able to reconstruct the original data stream perfectly, bit for bit, from the compressed version.

3

Which of the following statements best describes a significant trade-off of using lossy compression?

It typically results in a larger file than the original, but the data can be transmitted much more quickly.

It can only be applied to text data, making it unsuitable for multimedia files like images and videos.

In exchange for a smaller file size, some amount of the original data is permanently discarded.

The process is always reversible, but it requires special software to decompress the file to its original state.

Explanation

The core trade-off of lossy compression is quality for size. To achieve a smaller file size than what is typically possible with lossless methods, some of the original information is permanently removed. This trade-off is often acceptable for media files where the loss is not easily perceived.

4

Why is data compression a useful technique when sending information over the Internet?

Compression increases the resolution of images and the quality of audio files for the recipient.

Compression increases the security of the data by adding a layer of encryption that is difficult to break.

Compression reduces the number of bits that need to be transmitted, which can decrease download and upload times.

Compression automatically corrects any errors that occur during transmission, ensuring data integrity.

Explanation

The primary benefit of compression for data transmission is efficiency. By making the file size smaller, fewer bits need to be sent across the network, which reduces the time it takes to transfer the data and consumes less bandwidth.

5

A video streaming service prioritizes providing a smooth, uninterrupted playback experience for its users, who have a wide range of Internet connection speeds. Which compression strategy best supports this goal?

Lossless compression, to ensure that every frame of the video is delivered with perfect quality, which is the most important factor for viewer satisfaction.

Lossy compression, because it can significantly reduce the amount of data needed for streaming, preventing buffering even at the cost of some visual detail.

Sending the video uncompressed, to eliminate any processing delay from decompressing the video on the user's device and ensure immediate playback.

A hybrid approach where the video is compressed losslessly but the audio is compressed with a lossy algorithm to balance file size and quality.

Explanation

Streaming services use lossy compression to manage bandwidth constraints. By reducing the file size significantly, the video can be streamed smoothly over various internet speeds. The trade-off is a slight, often imperceptible, loss in quality, which is acceptable for the goal of avoiding buffering.

6

An e-commerce website displays small thumbnail images of products in its catalog. To ensure the catalog page loads as quickly as possible, which is the most appropriate strategy for handling these thumbnails?

Do not use any compression, to avoid putting extra processing load on the web server which could slow down the site.

Use lossless compression, because it is essential that the thumbnail image is a perfect representation of the product.

Use lossy compression, because a small reduction in the quality of a thumbnail is an acceptable trade-off for faster page loading.

Store the thumbnails in a text-based format, as text compresses better than image data and will result in faster load times.

Explanation

For preview images like thumbnails, the primary goal is fast delivery. A slight loss of quality is generally unnoticeable at such a small size and is a worthwhile trade-off for the significant reduction in file size and consequently faster page load times, which improves user experience.

7

Which statement accurately describes a key characteristic of lossy compression?

It typically results in a compressed file that is larger than the original but is optimized for faster network transfer.

It is a fully reversible process, meaning the original data can always be perfectly restored after decompression.

It is an irreversible process because the compression algorithm permanently removes some of the original data.

It is most effective on data with high redundancy, such as plain text documents with repeated words.

Explanation

The core principle of lossy compression is the permanent removal of data. This makes the process irreversible; once the data is discarded to reduce file size, it cannot be recovered. This is in direct contrast to lossless compression, which is a reversible process.

8

Read the passage. A cloud platform stores millions of customer documents and wants to reduce storage costs without changing any file contents. Data compression helps by representing repeated patterns more efficiently, lowering the number of bits needed to store data. Lossless compression is used when exact recovery matters, such as for text files, code, and spreadsheets, while lossy compression is common for media where small imperfections are acceptable. LZW is a lossless algorithm that builds a dictionary of repeated sequences and substitutes short codes, which can be effective when the same phrases or patterns appear many times. Huffman coding is also lossless, using shorter bit patterns for more frequent symbols. JPEG and MPEG, by contrast, are typically lossy and focus on shrinking images and video.

Which scenario best demonstrates the use of LZW compression?

Compressing repetitive server logs without altering any characters.

Improving audio clarity by adding extra data to the stream.

Shrinking a photo by discarding subtle visual details.

Reducing video size by predicting changes between frames.

Explanation

This question tests AP Computer Science Principles skills in understanding data compression, specifically identifying appropriate use cases for LZW compression. Data compression reduces file sizes by finding and encoding patterns, with LZW being a lossless method that builds a dictionary of repeated sequences and replaces them with shorter codes. In the provided passage, LZW is described as 'a lossless algorithm that builds a dictionary of repeated sequences and substitutes short codes, which can be effective when the same phrases or patterns appear many times.' Choice A is correct because server logs typically contain repetitive patterns (timestamps, IP addresses, error messages) that LZW can compress effectively without altering any characters, matching the lossless requirement. Choice B is incorrect because it describes lossy compression (discarding visual details), while LZW is explicitly lossless. To help students: Provide examples of repetitive data (logs, source code, structured documents) where LZW excels. Emphasize that LZW's dictionary approach works best with repeated patterns.

9

Read the passage. Streaming services rely on compression to deliver content efficiently across networks with varying speeds. Compression reduces the number of bits sent, which can prevent buffering and lower data usage. Lossless compression preserves exact data and is common for text like subtitles, while lossy compression is common for images and video because it can shrink files much more by discarding information viewers are less likely to notice. JPEG is a familiar lossy format for still images, and MPEG is widely used for video, often combining multiple strategies to reduce size. The main challenge is balancing smaller files against visible artifacts or reduced clarity. Services tune compression levels to maintain acceptable quality while keeping playback smooth.

Why is lossy compression preferred in many streaming video applications?

It achieves much smaller files, with tolerable quality loss.

It is required for subtitles because text can change safely.

It works by assigning shorter codes to frequent letters only.

It ensures every frame is restored with perfect accuracy.

Explanation

This question tests AP Computer Science Principles skills in understanding data compression, specifically why lossy compression is preferred for streaming video applications. Data compression reduces file sizes to enable efficient streaming, with lossy compression achieving much greater reduction by removing information viewers are unlikely to notice. In the provided passage, lossy compression for video is described as being able to 'shrink files much more by discarding information viewers are less likely to notice,' with the key benefit being prevention of buffering and smooth playback. Choice A is correct because it captures the essential trade-off: achieving much smaller files (enabling smooth streaming) with tolerable quality loss, as stated in the passage's discussion of balancing file size against artifacts. Choice B is incorrect because it describes lossless compression - the passage clearly states lossy compression discards information. To help students: Discuss real-world streaming constraints like bandwidth limitations and why perfect quality isn't always necessary. Use examples of quality settings in streaming platforms to illustrate the compression trade-offs.

10

Read the passage. In a streaming-service setting, data compression reduces the number of bits needed to store or transmit information. Compression works by finding patterns and representing them more efficiently, which helps platforms deliver movies, music, and captions quickly over limited bandwidth. Two broad categories appear: lossless compression preserves every original detail so the decompressed data matches exactly, while lossy compression removes some information to achieve smaller files. For text such as subtitles and chat logs, lossless methods are common because even a small change can alter meaning; Huffman coding assigns shorter bit patterns to frequent symbols, and LZW replaces repeated sequences with short codes. For images and video, lossy methods often dominate because the human eye tolerates small changes; JPEG compresses still images by discarding subtle visual details, and MPEG compresses video by combining spatial compression with frame-to-frame prediction. The trade-off is constant: stronger compression usually means smaller files but more noticeable artifacts, so services adjust settings to balance quality and smooth playback.

Based on the text, what trade-offs are involved in using JPEG compression?

It reduces file size but may introduce visible artifacts.

It increases file size to prevent any streaming delays.

It replaces repeated words with codes for perfect text accuracy.

It preserves every pixel while greatly shrinking files.

Explanation

This question tests AP Computer Science Principles skills in understanding data compression, specifically the trade-offs involved in lossy compression methods like JPEG. Data compression reduces file sizes by removing redundant information, with lossy compression achieving greater reduction by permanently discarding some data that may not be noticeable to users. In the provided passage, JPEG compression is described as discarding 'subtle visual details' to compress still images, while noting that 'stronger compression usually means smaller files but more noticeable artifacts.' Choice A is correct because it accurately captures both aspects of the JPEG trade-off: reduced file size (benefit) and potential visible artifacts (cost) as stated in the passage. Choice B is incorrect because it contradicts the lossy nature of JPEG - the passage clearly states JPEG 'discards subtle visual details,' not preserving every pixel. To help students: Focus on identifying key terms like 'trade-off' and 'artifacts' in compression contexts. Practice distinguishing between the benefits (smaller files) and costs (quality loss) of different compression methods.

Page 1 of 3