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.

In-content ad
  1. Question 1 · Easy

    How many different values can be represented using 3 bits?

    • A
      3
      Why not A: 3 is the number of bits, not the number of values. With n bits you get 2^n values, not n values.
    • B
      6
      Why not B: 6 = 2 × 3 is the result of multiplying instead of exponentiating. The correct formula is 2^3 = 8.
    • C
      8Correct
    • D
      16
      Why not D: 16 = 2^4 is the number of values representable with 4 bits, not 3.
    Explanation

    With 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 takeaway

    n bits represent 2^n distinct values: 1 bit → 2, 2 bits → 4, 3 bits → 8, 4 bits → 16, etc.

  2. Question 2 · Easy

    What is the decimal value of the 8-bit binary number 00001011?

    • A
      8
      Why not A: Only counts the bit in position 3 (value 8) and ignores the 1s in positions 1 and 0 (values 2 and 1).
    • B
      11Correct
    • C
      13
      Why not C: 13 = 8 + 4 + 1; this includes position 2 (value 4) which is 0 in this number.
    • D
      3
      Why not D: 3 = 2 + 1 ignores the bit in position 3 (value 8); only the rightmost two 1-bits were added.
    Explanation

    Convert 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 takeaway

    Binary-to-decimal: sum 2^position for each bit that is 1, counting positions from 0 on the right.

  3. Question 3 · Easy

    Which of the following BEST distinguishes lossy compression from lossless compression?

    • A
      Lossy 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.
    • B
      Lossless compression allows the original data to be perfectly reconstructed; lossy compression discards some information permanently and cannot perfectly reconstruct the original.Correct
    • C
      Lossy 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).
    • D
      Both 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.
    Explanation

    Lossless 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 takeaway

    Lossless: original perfectly recoverable. Lossy: some data permanently discarded for greater size reduction.

  4. Question 4 · Easy

    A photograph is stored in JPEG format (lossy compression) and then decompressed. Which of the following accurately describes the decompressed image?

    • A
      The 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.
    • B
      The 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.
    • C
      The decompressed image approximates the original but may differ in subtle ways because some information was permanently discarded.Correct
    • D
      The 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.
    Explanation

    JPEG 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 takeaway

    JPEG (lossy) decompression cannot restore discarded data; the image approximates the original but is not identical.

  5. 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?

    • A
      To 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.
    • B
      To represent the characters of virtually all human writing systems, including scripts not covered by ASCII.Correct
    • C
      To 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.
    • D
      To 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.
    Explanation

    ASCII'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 takeaway

    Unicode extends ASCII's 128-character limit to support virtually all written human languages and symbols globally.

  6. 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?

    • A
      Primary 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.
    • B
      Compressed 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.
    • C
      Metadata — data that describes other data, in this case when the records were created.Correct
    • D
      Encrypted 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.
    Explanation

    Metadata 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 takeaway

    Metadata is data that describes other data — timestamps, GPS coordinates, file sizes, and author names are common examples.

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

    • A
      Data 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.
    • B
      Metadata 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.
    • C
      Bias in data — the training data reflects historical discrimination, causing the model to perpetuate it.Correct
    • D
      Lossy 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.
    Explanation

    When 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 takeaway

    Biased training data causes models to learn and perpetuate those biases, producing unfair or discriminatory outcomes.

  8. 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 WWWWBBWW is encoded as 4W2B2W.

    Using this scheme, what is the compressed encoding of RRRRRRGGGG?

    • A
      6R4GCorrect
    • B
      4R6G
      Why 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
      RRRRRRGGGG
      Why not C: That is the original uncompressed string, not the RLE-encoded version.
    • D
      10RG
      Why 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.
    Explanation

    RLE scans the sequence and records each run of consecutive identical values as a count + value pair. RRRRRRGGGG has a run of 6 R's followed by a run of 4 G's, so it encodes as 6R4G. The compressed form uses 4 characters instead of 10, a 60% size reduction.

    Key takeaway

    Run-length encoding replaces each run of identical values with (count, value), working best on data with long repeated sequences.

  9. 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?

    • A
      The 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.
    • B
      The survey uses lossy compression, which distorted the responses.
      Why not B: Survey responses are not compressed data; lossy compression is unrelated to survey methodology.
    • C
      The 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
    • D
      The 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.
    Explanation

    The 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 takeaway

    Conclusions drawn from non-representative samples are biased; the population the sample is drawn from must match the population being described.

  10. Question 10 · Hard

    Which of the following is an example of data abstraction?

    • A
      Storing a student's grade as the number 92 rather than tracking every individual assignment score that contributed to it.Correct
    • B
      Compressing 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.
    • C
      Converting 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.
    • D
      Encrypting 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.
    Explanation

    Data 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 takeaway

    Data abstraction replaces complex, detailed data with a simpler representation that captures the essential meaning.

  11. 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?

    • A
      Reducing 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.
    • B
      Using 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.
    • C
      Increasing the sampling rate (e.g., from 44,100 Hz to 96,000 Hz) and using more bits per sample.Correct
    • D
      Applying 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.
    Explanation

    Digital 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 takeaway

    Digital audio accuracy increases with higher sampling rate (more samples/sec) and higher bit depth (more bits/sample).

  12. 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?

    • A
      The 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.
    • B
      Aggregating 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
    • C
      GPS 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.
    • D
      The 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.
    Explanation

    Each 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 takeaway

    Aggregating individually innocuous data points over time can expose sensitive behavioral patterns the user never intended to share.