AP Computer Science Principles
Advanced Placement Computer Science Principles covering the College Board CED's five Big Ideas: Creative Development, Data, Algorithms and Programming, Computer Systems and Networks, and Impact of Computing. Conceptual and language-agnostic, using AP CSP pseudocode.
Ämne: Teknik · Nivå: Gymnasium (16–19) · 410 kort
Innehåll
- A computing innovation includes a program as an integral part of its function. Examples: GPS navigation, smartphones, self-driving cars, social media platforms, ride-sharing apps.
- Collaboration in software development brings together diverse perspectives, skills, and knowledge. Effective collaborators communicate clearly, give constructive feedback, manage conflict, and divide tasks.
- Program requirements are specifications describing what the program will do. They are gathered from end users through interviews, surveys, observation, and prototype feedback.
- Program design phases typically include: investigating and reflecting (requirements), designing (planning), prototyping (building a draft), and testing/refining (debugging). The cycle is iterative — phases repeat as understanding grows.
- Program documentation explains how a program (or program segment) functions — written for collaborators, future maintainers, and end users. Includes inline comments, README files, API references, and user manuals.
- Comments are programmer-written explanations ignored by the compiler/interpreter. They describe intent, document complex logic, mark TODOs, or note edge cases — making code maintainable.
- A syntax error violates the rules of the programming language — like a typo or missing punctuation. The program will not run until syntax errors are fixed. Example: forgetting a closing brace.
- A runtime error occurs while the program is running, halting execution. Examples: dividing by zero, accessing a list index out of range, trying to convert non-numeric text to a number.
- A logic error lets the program run without crashing but produces wrong results because the algorithm or expression is incorrect. Example: using + instead of × in an average calculation.
- An overflow error happens when a calculation produces a value too large for the variable's storage (e.g., adding 1 to the maximum 32-bit integer). Modern languages often promote to bigger types automatically, but embedded systems may not.
- Debugging is the process of finding and fixing errors. Techniques: trace tables, print statements, breakpoints, rubber-duck explanation, isolating sections, comparing actual vs expected output.
- Testing checks whether a program meets its requirements. Test cases include typical inputs, boundary cases (smallest/largest valid input), and invalid inputs. Catching bugs early is cheaper than later.
- Iteration in development means returning to earlier phases as new understanding emerges. A program rarely succeeds in one straight pass — prototypes are tested, refined, and re-tested.
- Acknowledgement of contributors and use of third-party code (libraries, snippets) belongs in program documentation — both for ethical credit and to track licenses (MIT, GPL, Apache).
- Version control systems (e.g., Git) let developers track changes, revert mistakes, and collaborate on the same code base. Each commit records what changed, who, and when. Branches isolate features in progress.
- Pair programming pairs two developers at one computer — one types (driver), the other reviews (navigator). Roles rotate. Studies show fewer defects despite higher hours-per-task.
- Investigating user needs reveals requirements the developer might miss. User testing with people outside the dev team often uncovers assumptions the team takes for granted.
- Inputs to a program can come from users (keyboard, mouse, touchscreen), sensors (GPS, gyroscope, camera, microphone), files, or network requests. Outputs include screen display, audio, files saved, network responses, and device actuation.
- Events are inputs that trigger code: a mouse click, a key press, a sensor reading, a timer firing, or a network message arriving. Event-driven programs respond to events instead of running top-to-bottom.
- Prototyping builds a partial, rough version of a program to test ideas before full implementation. Paper sketches, wireframes, and minimal-code mockups are common prototypes.
- Different users have different needs. Inclusive design considers age, disability, language, device capability, and bandwidth from the start — rather than retrofitting accessibility late.
- Test cases should include normal inputs, edge cases (smallest, largest, empty), and invalid inputs. Each test states an input and the expected output — then compares actual output to confirm correctness.
- Identifying which line(s) of code cause a logic error often requires tracing execution by hand or using a debugger to step through statements while watching variable values.
- Code review is when peers read each other's code, suggesting improvements before it ships. Reviews catch logic bugs, improve clarity, share knowledge across the team, and enforce style.
- A bit is the smallest unit of digital data — a single 0 or 1. The word is a contraction of "binary digit".
- A byte is 8 bits and can represent 2⁸ = 256 distinct values (0–255 for unsigned, −128 to 127 for signed). File sizes and memory are commonly measured in bytes.
- n bits can represent 2ⁿ distinct values. So 4 bits → 16 values, 8 bits → 256, 16 bits → 65 536, 32 bits → ≈4.3 billion.
- Binary (base 2) uses only digits 0 and 1. Each place is a power of 2. Example: 1011₂ = 1×8 + 0×4 + 1×2 + 1×1 = 11₁₀.
- Decimal (base 10) uses digits 0–9. Each place is a power of 10. Example: 245₁₀ = 2×100 + 4×10 + 5×1.
- Hexadecimal (base 16) uses digits 0–9 and letters A–F (A=10, B=11, C=12, D=13, E=14, F=15). One hex digit fits exactly into 4 bits, making it compact for memory addresses and color codes.
- Hex color codes use 2 hex digits per channel: #RRGGBB. #FF0000 is pure red, #00FF00 pure green, #0000FF pure blue. #FFFFFF is white, #000000 black.
- An abstraction hides details to focus on essential features. Layered abstractions stack: transistors → logic gates → machine code → high-level language → user interface. Each layer rests on the one below.
- Analog data takes any value on a continuous range (sound waves, light intensity). Digital data uses discrete numeric values (samples).
- Sampling measures an analog signal at regular intervals and stores each measurement as a number. The result approximates the original — fidelity depends on sampling rate and bit depth.
- Sampling rate is how often a signal is measured per second (Hz). CD audio uses 44 100 Hz — high enough to capture sounds up to ≈20 kHz, the limit of human hearing.
- Bit depth is the number of bits used per sample. Higher bit depth = more distinct levels and finer resolution. CD audio uses 16 bits/sample = 65 536 amplitude levels.
- Lossless compression reduces file size without losing any data — the original is exactly recoverable. Examples: ZIP, PNG, FLAC, run-length encoding, Huffman coding.
- Lossy compression sacrifices some data quality to achieve much smaller files. The original cannot be perfectly restored. Examples: JPEG, MP3, MP4 — acceptable when perceptual quality matters more than exactness.
- Run-length encoding compresses runs of identical values into pairs of (value, count). "AAAAABBBCCDAA" → "A5B3C2D1A2" — lossless and effective on data with long repeating runs (some bitmap images, simple animations).
- Huffman coding is a lossless technique that assigns shorter bit sequences to frequent symbols and longer ones to rare symbols. The most common letter in English text (e) gets a very short code; rare letters (z, q) get longer ones.
- Compression ratio = compressed size ÷ original size (or expressed as a percentage). A 10 MB file compressed to 3 MB has a ratio of 0.3 (or 70% reduction).
- Encryption converts readable plaintext into unreadable ciphertext using a key. Only someone with the correct decryption key can recover the plaintext. Protects data both in transit (network) and at rest (disk).
- Symmetric encryption uses the same key for encrypting and decrypting. Both parties must share the secret key beforehand. Fast and used for bulk data, but key distribution is hard. Example: AES.
- Asymmetric (public-key) encryption uses a key pair: a public key (shared openly) encrypts; a matching private key (kept secret) decrypts. Solves key distribution — anyone can encrypt to you without prearranged secrets. Example: RSA.
- SSL/TLS (Secure Sockets Layer / Transport Layer Security) protects data in transit on the web. HTTPS is HTTP over TLS. Sites negotiate a session key using asymmetric encryption, then use fast symmetric encryption for the actual data.
- A Caesar cipher shifts each letter by a fixed amount in the alphabet — A→D, B→E with shift 3. Easy to break by trying all 25 shifts (brute force). Symmetric: same shift used to decrypt.
- Cleaning data is the process of fixing or removing inaccurate, incomplete, duplicate, or inconsistent records before analysis. Examples: trim whitespace, standardize date formats, drop nulls, merge duplicates, fix encoding.
- Metadata is data about data — a photo's EXIF (when, where, camera, settings); an MP3's ID3 (artist, title, length); an email's headers (sender, time, route). Useful for search, indexing, and inference, but also a privacy risk.
- Big data refers to data sets so large or complex that traditional tools cannot store or analyze them efficiently. Often characterized by the "three Vs": Volume (size), Velocity (arrival speed), Variety (formats).
- Personally Identifiable Information (PII) is any data that can identify a specific person. Direct PII: name, government ID, biometrics. Indirect/quasi: zip code + birth date + gender can together identify most individuals.