AP Computer Science Principles · Unit 2 · 17-22% of the exam · about 75 minutes

Unit 2: Data

By the end: Represent numbers, text, colors and sound in binary, explain overflow, round-off and sampling, choose between lossless and lossy compression, and use programs to clean, filter, transform and visualize data while avoiding false conclusions about cause and bias.

Mr. Thompkins
  1. 2.1 Binary numbers: bits and abstraction · 6 min

    Everything is ones and zeros

    • A bit is a binary digit, 0 or 1. A byte is 8 bits.
    • Bits are grouped to represent abstractions such as numbers, characters and colors.
    • The same sequence of bits can mean different things in different contexts.
  2. 2.1 Binary numbers: converting · 9 min

    Counting in base 2

    • Binary is base 2. Places from the right: 1, 2, 4, 8, 16, 32, 64, 128.
    • Binary to decimal: add the place values under each 1.
    • Decimal to binary: take out the biggest power of 2 that fits, and repeat.
  3. 2.1 Binary numbers: how many values · 7 min

    Each bit doubles your options

    • n bits make 2ⁿ patterns. Each extra bit doubles the count.
    • As whole numbers from 0, n bits hold 0 to 2ⁿ - 1.
    • Minimum bits for k items: the smallest n with 2ⁿ ≥ k.
  4. 2.1 Overflow and round-off · 8 min

    When fixed bits run out

    • Fixed-size integers have a limited range. A result outside it is an overflow error.
    • Some languages, including the exam's pseudocode, limit integers only by memory, so they don't overflow.
    • Real numbers are stored with a fixed number of bits, so many are approximations: round-off errors.
  5. 2.1 Analog data and sampling · 7 min

    Turning smooth signals into numbers

    • Analog data change smoothly. Digital data are separate values.
    • Sampling measures an analog signal at regular intervals; each sample is stored in bits.
    • More samples, or more bits per sample: closer approximation, bigger file.
  6. 2.2 Data compression: lossless · 8 min

    Same information, fewer bits

    • Compression reduces the number of bits for stored or transmitted data. Fewer bits does not necessarily mean less information.
    • Lossless: the original can be reconstructed exactly, every bit.
    • How much a file shrinks depends on its redundancy and on the compression algorithm.
  7. 2.2 Data compression: lossy · 7 min

    Smaller still, if you can live with "almost"

    • Lossy: can greatly reduce bits, but only an approximation of the original can be reconstructed.
    • Use lossless when quality or exact reconstruction is maximally important.
    • Use lossy when minimizing size or transmission time is maximally important.
  8. 2.3 Extracting information from data · 8 min

    From numbers to knowledge

    • Information is the facts and patterns extracted from data. Combining sources often reveals more.
    • Metadata are data about data. Used to find, organize and manage data; changing them doesn't change the data.
    • A correlation in data does not necessarily mean causation. More research is needed.
  9. 2.3 Data challenges: cleaning, bias and scale · 8 min

    Messy, biased and huge

    • Data can be incomplete, invalid or inconsistent. Cleaning makes it uniform without changing its meaning.
    • Bias often comes from the type or source of the data. Collecting more data does not remove it.
    • Large data sets may need more powerful tools or parallel systems. Scalability is handling growth.
  10. 2.4 Using programs with data · 9 min

    Filter, transform, combine, visualize

    • Programs process data to reveal information: filter, transform, combine or compare, sort, visualize, cluster and classify.
    • Filter: FOR EACH with an IF that decides what to APPEND. Transform: APPEND a changed copy of every item.
    • Combining data sources and visualizing data often reveal patterns that a single list hides.
  11. Unit 2 wrap-up · 6 min

    Put it together