All 5 CS Principles units
💡
AP Computer Science Principles · Unit 2 of 5

Data

17–22% of the exam4 lessons · 51 min36 terms

What this unit covers

The topics below follow the published CS Principles course framework for Unit 2. This unit is worth 17–22% of the exam, so budget your time against that rather than against how long the unit takes to teach.

BinaryData compressionExtracting informationBias

Lessons in this unit

Formulas in Unit 2

Range of n bits
patterns = 2ⁿ · largest unsigned value = 2ⁿ − 1
n bits produce 2ⁿ distinct patterns, representing the integers 0 through 2ⁿ − 1. Each added bit doubles the number of representable values.
Compression ratio
compression ratio = original size / compressed size
A ratio of 4:1 means the compressed data is one-quarter the original size. Equivalently, space saved = (original − compressed) / original.

Every term in Unit 2

All 36 terms we publish for Data, with definitions. Reading them through is the fastest way to find the ones you cannot define — then drill those in cram mode until you can produce them without the prompt.

Data abstraction
Using a name to represent a collection of data — a list rather than many separate variables. It lets a program work with any number of items using the same code.
Bit
A single binary digit, 0 or 1. The smallest unit of digital data.
Byte
Eight bits. Enough to represent 256 distinct values.
Binary number system
Base 2, using only 0 and 1. Place values are 1, 2, 4, 8, 16, 32, 64, 128 reading right to left.
Converting binary to decimal
Add the place values wherever there is a 1. So 1011 is 8 + 0 + 2 + 1 = 11.
Converting decimal to binary
Repeatedly subtract the largest power of 2 that fits, writing 1 for each one used and 0 otherwise. Or divide by 2 repeatedly and read the remainders bottom to top.
Number of values in n bits
2 to the power n. Four bits give 16 values, eight bits give 256 — and this is the calculation behind almost every "how many bits do you need" question.
Why digital data is discrete
Computers store finite sequences of bits, so they can only represent a finite set of values. Continuous real-world quantities must be approximated.
Analog vs digital data
Analog data varies continuously — sound pressure, light intensity. Digital data is discrete. Converting analog to digital always involves sampling and therefore approximation.
Sampling
Measuring an analog signal at regular intervals to make it digital. More frequent samples and more bits per sample give a closer approximation and a larger file.
Round-off error
Error from storing a number with limited precision. It accumulates over repeated calculations, which is why floating-point sums can drift.
Overflow vs round-off
Overflow is a number too large to store at all. Round-off is a number stored with insufficient precision. Different failures, and the exam distinguishes them.
Abstraction
Removing detail to manage complexity, and the central idea of the whole course. A variable name, a procedure, and a high-level language are all abstractions.
Lossless compression
Reducing file size with no information lost; the original is exactly recoverable. Used where every bit matters — text, code, archives.
Lossy compression
Reducing file size by discarding information, so the original cannot be exactly recovered. Achieves far smaller files, and is acceptable where human perception will not notice.
Choosing lossy or lossless
Lossy when the file is large, perception-limited and will not be edited further — streaming video, photographs. Lossless when exactness is required or the file will be re-edited.
Metadata
Data about data — file size, creation date, author, image dimensions, location. It can reveal more than the file itself, which is why it is a privacy topic as well as a data topic.
Information vs data
Data is raw values. Information is what those values mean once they are collected, cleaned and interpreted. The exam asks what can and cannot be concluded.
Data cleaning
Removing errors, duplicates and inconsistencies before analysis — standardizing formats, handling missing values. Skipping it produces confident wrong conclusions.
Filtering data
Selecting a subset that meets a condition. Reduces the data to what a question actually needs.
Data visualization
Presenting data graphically to reveal patterns. A well-chosen chart makes a trend visible; a poorly chosen one can imply a relationship that is not there.
Correlation vs causation
Two things moving together does not mean one causes the other. A standard exam trap on the data-analysis questions.
Bias in data collection
When a dataset systematically misrepresents the population — a survey reaching only smartphone users, a sensor only in wealthy neighborhoods. The conclusions inherit the bias.
Bias in a program
Bias can enter from the data used, from the assumptions built into the algorithm, or from who was in the room when it was designed. All three are examinable.
Scalability
Whether an approach still works as the data grows. Something manageable for a hundred records may be impossible for a hundred million.
Cleaning vs filtering
Cleaning fixes bad data. Filtering removes data you do not need. Cleaning improves quality; filtering narrows scope.
Why large datasets need programs
Volume beyond human reading. Programs can search, sort, filter and summarize at a scale a person cannot, which is exactly why bias in those programs is consequential.
Open data
Data made freely available for anyone to use. Enables collaboration and verification, and raises questions about consent and privacy for the people in it.
Personally identifiable information (PII)
Data that can identify a specific individual — name, address, biometrics, and combinations that become identifying together. Location plus timestamp is often PII even when neither is alone.
Aggregating data
Combining records to produce a summary such as a count, average or total. Aggregation can protect privacy — or fail to, when the group is small enough to identify.
Text as binary
Characters are stored as numbers under an encoding such as ASCII or Unicode, and those numbers are stored as bits. There is no text at the hardware level.
Images as binary
An image is a grid of pixels, each stored as numbers for its color components. More bits per pixel means more distinguishable colors and a larger file.
Sound as binary
Sound is sampled at intervals, each sample stored as a number. Sample rate and bit depth together determine fidelity and file size.
Why the same bits can mean different things
A sequence of bits has no meaning without a convention for reading it. The same byte can be a number, a character or part of a color depending on the program.
Data compression ratio
Compressed size divided by original size. A smaller ratio means more compression; the exam usually asks you to compare two schemes rather than compute one.
Extracting information from data
Using filtering, sorting, aggregating and visualizing to answer a question the raw data does not answer directly. Name the operation, not just the conclusion.

What examiners penalize here

Practice CS Principles

Our practice bank is drawn from across the whole course rather than filtered to one unit, which is closer to how the exam asks anyway — it will not tell you which unit a question is testing.

Questions about this unit

How much of the AP Computer Science Principles exam is Unit 2?

Unit 2, Data, is worth 17–22% of the CS Principles multiple-choice section according to the published course framework. Across all 5 units that makes it one of the heaviest units on the exam, and worth front-loading.

What topics are covered in CS Principles Unit 2?

Data covers Binary, Data compression, Extracting information and Bias. We publish 36 terms with definitions for this unit, all of them on this page.

How should I study CS Principles Unit 2?

Read the 4 lessons below first — about 50 minutes — then drill the 36 terms in cram mode until you can produce each definition from memory rather than just recognize it. Recognition is what makes a unit feel finished when it is not. Finish with practice questions and read the explanation for every one you get right by elimination as well as the ones you miss.

All 5 units of AP Computer Science Principles

  1. Unit 1 · Creative Development
  2. Unit 2 · Data
  3. Unit 3 · Algorithms & Programming
  4. Unit 4 · Computer Systems & Networks
  5. Unit 5 · Impact of Computing

Unit names, topics and exam weights follow the published College Board course framework for AP Computer Science Principles. AP® is a trademark registered by the College Board, which does not endorse this site.