Cheat sheets

AP Computer Science Principles / Chapter 2

Data

Cheat sheet

Binary representations

  • A bit is 0 or 1; a byte contains eight bits. Meaning depends on the encoding: the same pattern can represent a number, character or color. Constants, variables, lists and procedure inputs all represent data.
  • Binary position weights double from right to left: 1, 2, 4, 8, 16, 32. Sum weights at set positions to decode; select powers of two to encode. Compare equal-width unsigned strings from the leftmost differing bit.
  • An unsigned n-bit field has 2n2^{n} patterns and consecutive values from 0 through 2n−12^{n}-1 Overflow exceeds the range; the response depends on the system. Memory-limited integer abstractions expand storage instead.
  • Round-off reflects finite precision, even within range. Sampling approximates a changing analog quantity at selected times. Sample rate times bits per sample gives sample-value bits per second; timing and value precision are separate limits.

Compression choices

  • Lossless methods reconstruct their input exactly. Redundancy can permit fewer bits without less information, but encoding overhead can enlarge some inputs.
  • Lossy methods merge or discard distinctions. An acceptable appearance does not establish exact recovery. A later lossless save preserves the lossy result, not discarded source detail.
  • Choose by fidelity and resource constraints, measuring candidate methods on the actual input. A compressed size is not a universal ratio; both data and algorithm matter. At a fixed link rate, transfer time is file size divided by rate.

Evidence and preparation

  • Information consists of facts and patterns extracted from data. Correlation is association, not by itself evidence of causation or a guaranteed forecast. Missing fields can require compatible additional sources.
  • Metadata such as date, creator and location support discovery, structure and management. A metadata edit does not itself edit primary text, pixels or sound; descriptive fields can also be wrong.
  • Cleaning standardizes equivalent representations while preserving meaning. Keep missing and invalid observations distinguishable from genuine zeroes. A larger restricted sample can retain bias.
  • Scalability concerns workload growth. User skills, memory, storage and processing capacity limit feasible analysis; parallel processing can divide suitable work without repairing missing or biased evidence.

Processing data

  • Transform each value, filter matching records, and aggregate the selected values according to the question. Counts, totals and rates answer different questions; preserve units and denominators.
  • Join sources using shared keys at compatible time and observation levels. Check unmatched records and repeated values before summing; matching row order is unsafe.
  • Search locates records and filters narrow them. Spreadsheets support formulas, recalculation and summaries. Tables preserve exact values, line graphs show time patterns and bar charts compare categories.
  • Interactive analysis revisits operations after inspecting results. Clustering discovers similarity groups; classification assigns predefined labels. Neither a grouping nor a chart supplies a causal explanation by itself.

Sign in