0
0
Intro to Computingfundamentals~20 mins

Data compression basics in Intro to Computing - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Data Compression Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the main goal of data compression?

Imagine you have a large box of books and you want to fit them into a smaller box without losing any pages. What is the main goal of data compression in computing?

ATo reduce the size of data so it takes up less space or bandwidth
BTo make data load slower to save energy
CTo change the data into a secret code for security
DTo delete parts of data to save space
Attempts:
2 left
💡 Hint

Think about how you can fit more books in a smaller box without losing any pages.

trace
intermediate
2:00remaining
Trace the output of a simple run-length encoding

Run-length encoding (RLE) compresses data by replacing repeated characters with a count and the character. What is the output of encoding the string AAAABBBCCDAA using RLE?

Intro to Computing
Input: AAAABBBCCDAA
Output: ?
A4A3B2CDAA
BA4B3C2D1A2
CAAAA3BBB2CC1D2AA
D4A3B2C1D2A
Attempts:
2 left
💡 Hint

Count how many times each character repeats consecutively and write the count before the character.

identification
advanced
2:00remaining
Identify the type of compression from description

Which type of compression uses a dictionary of repeated patterns and replaces repeated data with references to this dictionary?

ARun-length encoding
BDictionary-based compression
CLossy compression
DHuffman coding
Attempts:
2 left
💡 Hint

Think about a compression method that builds a list of common pieces and reuses them.

Comparison
advanced
2:00remaining
Compare lossless and lossy compression

Which statement correctly compares lossless and lossy compression?

ABoth lossless and lossy compression remove data permanently.
BLossless compression loses some data to reduce size; lossy compression keeps all data intact.
CLossless compression keeps all original data; lossy compression removes some data to reduce size.
DLossy compression is slower than lossless compression in all cases.
Attempts:
2 left
💡 Hint

Think about whether the original data can be perfectly restored after compression.

🔍 Analysis
expert
2:00remaining
What is the output of this Huffman coding frequency table?

Given the characters and their frequencies: {'a': 5, 'b': 9, 'c': 12, 'd': 13, 'e': 16, 'f': 45}, what is the length of the Huffman code for character 'f'?

Intro to Computing
Frequencies: a=5, b=9, c=12, d=13, e=16, f=45
Question: Length of Huffman code for 'f'?
A1
B3
C4
D5
Attempts:
2 left
💡 Hint

In Huffman coding, the most frequent character gets the shortest code.