AP Computer Science Principles Data — Worked Answer Explanations
Unit 2 · 12 questions explained
Below is a complete answer key for our AP Computer Science Principles Data practice questions. For each question you'll find the correct choice, a full written explanation of how to get there, and — for every wrong answer — a short note on exactly why it's tempting and where it goes wrong. Reading these straight through is one of the fastest ways to find the gaps in a unit before exam day.
Prefer to test yourself first? Take the timed Data practice test and come back here to review, or head back to the Data unit overview.
- Question 1 · Easy
How many different values can be represented using 3 bits?
- A3Why not A: 3 is the number of bits, not the number of values. With n bits you get 2^n values, not n values.
- B6Why not B: 6 = 2 × 3 is the result of multiplying instead of exponentiating. The correct formula is 2^3 = 8.
- C8Correct
- D16Why not D: 16 = 2^4 is the number of values representable with 4 bits, not 3.
ExplanationWith n bits you can represent 2^n distinct values, because each bit has 2 possible states (0 or 1) and they combine independently. For 3 bits: 2^3 = 8. The values are 000, 001, 010, 011, 100, 101, 110, 111.
Key takeawayn bits represent 2^n distinct values: 1 bit → 2, 2 bits → 4, 3 bits → 8, 4 bits → 16, etc.
- A
- Question 2 · Easy
What is the decimal value of the 8-bit binary number
00001011?- A8Why not A: Only counts the bit in position 3 (value 8) and ignores the 1s in positions 1 and 0 (values 2 and 1).
- B11Correct
- C13Why not C: 13 = 8 + 4 + 1; this includes position 2 (value 4) which is 0 in this number.
- D3Why not D: 3 = 2 + 1 ignores the bit in position 3 (value 8); only the rightmost two 1-bits were added.
ExplanationConvert each bit's position to a power of 2 and sum where the bit is 1:
- Position 3 (bit = 1): 2^3 = 8
- Position 1 (bit = 1): 2^1 = 2
- Position 0 (bit = 1): 2^0 = 1
Sum: 8 + 2 + 1 = 11.
Key takeawayBinary-to-decimal: sum 2^position for each bit that is 1, counting positions from 0 on the right.
- A
- Question 3 · Easy
Which of the following BEST distinguishes lossy compression from lossless compression?
- ALossy compression always produces a smaller file than lossless compression for any type of data.Why not A: For some data types (e.g., already-random data) neither method compresses well, and the comparison depends on content.
- BLossless compression allows the original data to be perfectly reconstructed; lossy compression discards some information permanently and cannot perfectly reconstruct the original.Correct
- CLossy compression is used only for text files; lossless compression is used only for images.Why not C: This is backwards and wrong: text is typically lossless (e.g., ZIP), images can use either (PNG is lossless, JPEG is lossy).
- DBoth lossy and lossless compression permanently remove data to reduce file size.Why not D: Lossless compression does NOT permanently remove data; the original can be fully restored.
ExplanationLossless compression (e.g., ZIP, PNG) encodes data more efficiently without discarding any information — decompression perfectly restores the original. Lossy compression (e.g., JPEG, MP3) achieves higher compression ratios by permanently discarding information judged to be less perceptually important; the original cannot be reconstructed exactly.
Key takeawayLossless: original perfectly recoverable. Lossy: some data permanently discarded for greater size reduction.
- A
- Question 4 · Easy
A photograph is stored in JPEG format (lossy compression) and then decompressed. Which of the following accurately describes the decompressed image?
- AThe decompressed image is identical to the original photograph because decompression always restores all data.Why not A: JPEG is lossy: some pixel data is permanently discarded during compression, so decompression cannot restore the exact original.
- BThe decompressed image has the same file size as the original uncompressed photograph.Why not B: After decompression the file may expand back to a large size, but it will not be identical to the original because data was lost.
- CThe decompressed image approximates the original but may differ in subtle ways because some information was permanently discarded.Correct
- DThe decompressed image is completely unrecognizable because lossy compression destroys most of the image data.Why not D: Lossy compression discards imperceptible or less-important detail, not most of the image; JPEG images remain visually recognizable.
ExplanationJPEG uses lossy compression: high-frequency detail and subtle color variations are discarded during encoding. When the JPEG is decompressed, the missing data cannot be recovered — the result is an approximation of the original. At high quality settings the difference is imperceptible, but the files are not bit-for-bit identical.
Key takeawayJPEG (lossy) decompression cannot restore discarded data; the image approximates the original but is not identical.
- A
- Question 5 · Easy
ASCII uses 7 bits to encode each character, allowing it to represent 2^7 = 128 characters. Unicode (UTF-32) uses 32 bits per character. Why was Unicode developed?
- ATo compress text files so they take up less storage space.Why not A: Unicode uses more bits per character than ASCII, making files larger, not smaller. Its purpose is to extend the character set, not compress.
- BTo represent the characters of virtually all human writing systems, including scripts not covered by ASCII.Correct
- CTo make programs run faster by replacing multi-byte sequences with single bytes.Why not C: Unicode does not improve program speed; it addresses character coverage, not performance.
- DTo eliminate the need for binary representation in modern computers.Why not D: Unicode is still binary; it simply uses more bits to encode a vastly larger set of characters.
ExplanationASCII's 128-character limit covers only basic Latin letters, digits, and punctuation — it cannot represent Chinese characters, Arabic script, emoji, or thousands of other symbols used worldwide. Unicode was developed to provide a universal character set for virtually all human languages and scripts. UTF-32's 32 bits allow over 4 billion code points.
Key takeawayUnicode extends ASCII's 128-character limit to support virtually all written human languages and symbols globally.
- A
- Question 6 · Easy
A hospital stores patient records in a database. Each record includes the patient's name, date of birth, diagnosis codes, and the date each entry was created. The dates and times when entries were created are examples of which type of data?
- APrimary data — the most important data in the record.Why not A: "Primary data" is not a standard CSP term for timestamps that describe when other data was created.
- BCompressed data — the dates are stored more efficiently than the diagnosis codes.Why not B: There is no indication of compression; this answer conflates storage format with data type.
- CMetadata — data that describes other data, in this case when the records were created.Correct
- DEncrypted data — the dates are hidden to protect patient privacy.Why not D: Encryption protects data confidentiality; timestamps are described here as descriptive information, not encrypted content.
ExplanationMetadata is data about data. The creation timestamp of a patient record describes WHEN the record was entered, not the medical content of the record itself. Other metadata examples include a photo's GPS location and camera settings, a document's author and modification date, and a file's size and creation time.
Key takeawayMetadata is data that describes other data — timestamps, GPS coordinates, file sizes, and author names are common examples.
- A
- Question 7 · Medium
A data analyst trains a machine learning model to predict loan approval using historical loan data. She later discovers that the historical data reflects past discriminatory lending practices that denied loans to certain demographic groups at higher rates. The model learns from this pattern and replicates it.
This scenario BEST illustrates which concern about data?
- AData compression — the training data was compressed, removing important information.Why not A: The problem is not about compression or missing bits; it is about biased patterns embedded in the historical data.
- BMetadata corruption — the timestamps on the records were inaccurate.Why not B: Timestamp accuracy is irrelevant here; the issue is discriminatory patterns in the content of the historical data.
- CBias in data — the training data reflects historical discrimination, causing the model to perpetuate it.Correct
- DLossy encoding — some loan applications were discarded during digitization.Why not D: Lossy encoding refers to compression that discards data for size reduction, not historical discrimination patterns in a dataset.
ExplanationWhen training data reflects historical human biases — such as discriminatory lending — a model trained on that data will learn those biased patterns and reproduce them in new predictions. This is data bias: the data does not represent reality fairly, so the model's outputs are unfair. It is a major ethical concern in data science and AI.
Key takeawayBiased training data causes models to learn and perpetuate those biases, producing unfair or discriminatory outcomes.
- A
- Question 8 · Medium
A run-length encoding (RLE) scheme compresses a row of pixels by replacing consecutive identical values with a count and the value. For example, the row
WWWWBBWWis encoded as4W2B2W.Using this scheme, what is the compressed encoding of
RRRRRRGGGG?- A
6R4GCorrect - B
4R6GWhy not B: Swapped the counts: there are 6 R's followed by 4 G's, not 4 R's followed by 6 G's. - C
RRRRRRGGGGWhy not C: That is the original uncompressed string, not the RLE-encoded version. - D
10RGWhy not D: 10RG would mean 10 of the sequence RG, not 6 of R followed by 4 of G. The two colors must be encoded separately.
ExplanationRLE scans the sequence and records each run of consecutive identical values as a count + value pair.
RRRRRRGGGGhas a run of 6 R's followed by a run of 4 G's, so it encodes as6R4G. The compressed form uses 4 characters instead of 10, a 60% size reduction.Key takeawayRun-length encoding replaces each run of identical values with (count, value), working best on data with long repeated sequences.
- A
- Question 9 · Medium
A survey of 10,000 adults asks: "Do you use social media daily?" Results show 68% say yes. A researcher concludes that 68% of all humans use social media daily.
Which flaw in this data analysis is MOST significant?
- AThe sample size is too small — surveys need at least 1 million respondents to draw valid conclusions.Why not A: 10,000 is actually a large sample for most surveys; sample size alone is not the primary flaw here.
- BThe survey uses lossy compression, which distorted the responses.Why not B: Survey responses are not compressed data; lossy compression is unrelated to survey methodology.
- CThe conclusion overgeneralizes from a non-representative sample — adults surveyed in one context may not represent all humans (including children and people without internet access).Correct
- DThe binary yes/no encoding of responses is insufficient and introduces rounding errors.Why not D: A yes/no question is appropriate for this type of survey and does not introduce rounding errors.
ExplanationThe survey sampled adults (excluding children), likely in internet-connected regions (excluding the roughly 2.7 billion people without internet access), and possibly in specific languages (excluding others). Extrapolating this to "all humans" is an overgeneralization from a non-representative sample — a classic form of sampling bias. The sample size of 10,000 is not the issue; representativeness is.
Key takeawayConclusions drawn from non-representative samples are biased; the population the sample is drawn from must match the population being described.
- A
- Question 10 · Hard
Which of the following is an example of data abstraction?
- AStoring a student's grade as the number 92 rather than tracking every individual assignment score that contributed to it.Correct
- BCompressing an image file so it takes up less disk space.Why not B: Compression reduces file size; it does not simplify a complex data structure into a higher-level representation.
- CConverting a decimal number to binary so a computer can store it.Why not C: Decimal-to-binary conversion is encoding (changing representation format), not data abstraction.
- DEncrypting a file so unauthorized users cannot read it.Why not D: Encryption hides content for security; it does not simplify or abstract a complex data structure.
ExplanationData abstraction means representing a complex piece of information with a simpler, higher-level value that captures what matters for the current purpose. Storing a single grade of 92 abstracts away the complexity of dozens of individual scores. Users of the grade only need the summary, not all the raw details. Compression, encoding, and encryption are different operations.
Key takeawayData abstraction replaces complex, detailed data with a simpler representation that captures the essential meaning.
- A
- Question 11 · Hard
A digital audio file encodes sound by sampling the audio signal at regular intervals (e.g., 44,100 times per second) and storing each sample as a binary number. Which of the following changes would INCREASE the accuracy of the digital audio representation?
- AReducing the sampling rate from 44,100 Hz to 22,050 Hz.Why not A: Reducing the sampling rate captures fewer data points per second, which decreases accuracy and can cause aliasing artifacts.
- BUsing fewer bits per sample (e.g., from 16 bits to 8 bits).Why not B: Fewer bits per sample means fewer distinct amplitude levels, which decreases accuracy and introduces quantization noise.
- CIncreasing the sampling rate (e.g., from 44,100 Hz to 96,000 Hz) and using more bits per sample.Correct
- DApplying lossy compression to the sampled audio data.Why not D: Lossy compression discards some audio data to reduce file size, which decreases accuracy, not increases it.
ExplanationDigital audio accuracy depends on two parameters: sampling rate (how often per second the signal is measured) and bit depth (how many distinct amplitude levels can be represented per sample). Higher sampling rate captures higher-frequency sounds more accurately; higher bit depth (more bits per sample) captures amplitude variations more precisely. Reducing either, or applying lossy compression, decreases accuracy.
Key takeawayDigital audio accuracy increases with higher sampling rate (more samples/sec) and higher bit depth (more bits/sample).
- A
- Question 12 · Hard
A health app automatically logs a user's GPS location every 5 minutes throughout the day. Over a year, this produces a detailed record of everywhere the user went.
Which of the following BEST describes a privacy concern raised by this data collection practice?
- AThe GPS data uses too many bits per coordinate, wasting storage space.Why not A: Storage efficiency is a technical concern, not the primary privacy concern raised by location logging.
- BAggregating location data over time creates a detailed behavioral profile that can reveal sensitive information (home/work address, medical visits, religious attendance) even if each data point seems harmless.Correct
- CGPS coordinates are stored as floating-point numbers, which introduces rounding errors that distort the user's location.Why not C: Floating-point precision is a technical concern unrelated to the privacy implications of long-term location tracking.
- DThe app should use lossless compression on the location data to prevent privacy breaches.Why not D: Compression type has no bearing on privacy; the concern is what the collected data reveals, not how it is stored.
ExplanationEach individual GPS coordinate seems innocuous — a point on a map at a moment in time. But aggregated over months, the pattern reveals where the user sleeps (home), works (office), receives medical care (clinic), worships (house of worship), and socializes. This aggregation of individually benign data points into a rich behavioral profile is the core privacy concern: it can expose information the user never intended to share and can be used for surveillance, discrimination, or manipulation.
Key takeawayAggregating individually innocuous data points over time can expose sensitive behavioral patterns the user never intended to share.
- A