1/24
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Algorithm
A step-by-step procedure for solving a problem; in AP CSA, turning an idea into precise Java code that works for all cases (including edge cases).
Selection
A control structure where the program chooses different paths of execution based on a boolean condition (e.g., using if / if-else / else if).
Iteration
A control structure that repeats a block of code, either while a condition remains true or for a set number of times (using while or for loops).
Boolean expression
An expression that evaluates to true or false; used as the condition in if statements and loop headers.
if-else if-else chain
A selection structure where conditions are checked in order; the first true condition’s block runs and the rest are skipped.
Misordered/overlapping conditions
A logic error where an earlier condition makes later branches unreachable (e.g., checking score >= 80 before score >= 90).
Short-circuit evaluation
In && and || expressions, Java evaluates left to right and may stop early (e.g., if left side of && is false, the right side is not evaluated).
while loop
A loop that repeats as long as its boolean condition is true; the condition is checked before each iteration, so the body may run zero times.
Sentinel condition
A stopping condition used with loops when the number of repetitions is unknown in advance (the loop ends when the sentinel is reached).
Infinite loop
A loop that never terminates, commonly caused by forgetting to update a loop variable (e.g., missing i++).
for loop
A count-controlled loop with initialization, continuation condition, and update; best when the number of iterations is known (e.g., iterating over an index range).
Off-by-one error
A boundary mistake in loop conditions or indices (e.g., using i <= s.length() instead of i < s.length()).
Counting occurrences pattern
A loop algorithm pattern that increments a counter only when a condition is met (often using an if inside the loop).
Accumulation pattern
A loop algorithm pattern that maintains a running result, such as sum/product or a built string, updated each iteration or conditionally.
Maximum/minimum (best-so-far) pattern
A pattern that tracks the current max/min value and updates it when a better value is found; requires careful initialization to a valid starting value.
Early termination
Stopping a loop as soon as the answer is known (often via return inside the loop), reducing unnecessary iterations in many cases.
Nested loop
A loop inside another loop; the inner loop runs fully for each iteration of the outer loop, greatly increasing total iterations.
String
An immutable Java object representing a sequence of characters; many Unit 2 algorithms iterate through its characters using indices.
String.length()
Returns the number of characters in a string; the last valid index is length() - 1.
String.charAt(int index)
Returns the character at the given index; throws StringIndexOutOfBoundsException if index is not in 0..length()-1.
String.substring(int start, int end)
Returns a new string from start (inclusive) to end (exclusive); requires bounds that keep end within the string length.
String immutability
The property that strings cannot be changed in place; any modification creates a new string (e.g., building a result via concatenation).
String.equals(String other)
Compares string contents for equality; preferred over == for checking if two strings have the same characters.
StringIndexOutOfBoundsException
A runtime error caused by accessing invalid string indices (e.g., calling charAt(length()) or substring past the end).
Loop invariant
A statement that remains true at a key point in every loop iteration (often used informally to explain what a variable represents and why the algorithm is correct).