Unit 2 Algorithms and Analysis: Building, Using, and Reasoning About Code

0.0(0)
Studied by 0 people
0%Unit 2 Mastery
0%Exam Mastery
Build your Mastery score
multiple choiceMultiple Choice
call kaiCall Kai
Supplemental Materials
Card Sorting

1/24

Last updated 3:08 PM on 3/12/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

25 Terms

1
New cards

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).

2
New cards

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).

3
New cards

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).

4
New cards

Boolean expression

An expression that evaluates to true or false; used as the condition in if statements and loop headers.

5
New cards

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.

6
New cards

Misordered/overlapping conditions

A logic error where an earlier condition makes later branches unreachable (e.g., checking score >= 80 before score >= 90).

7
New cards

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).

8
New cards

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.

9
New cards

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).

10
New cards

Infinite loop

A loop that never terminates, commonly caused by forgetting to update a loop variable (e.g., missing i++).

11
New cards

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).

12
New cards

Off-by-one error

A boundary mistake in loop conditions or indices (e.g., using i <= s.length() instead of i < s.length()).

13
New cards

Counting occurrences pattern

A loop algorithm pattern that increments a counter only when a condition is met (often using an if inside the loop).

14
New cards

Accumulation pattern

A loop algorithm pattern that maintains a running result, such as sum/product or a built string, updated each iteration or conditionally.

15
New cards

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.

16
New cards

Early termination

Stopping a loop as soon as the answer is known (often via return inside the loop), reducing unnecessary iterations in many cases.

17
New cards

Nested loop

A loop inside another loop; the inner loop runs fully for each iteration of the outer loop, greatly increasing total iterations.

18
New cards

String

An immutable Java object representing a sequence of characters; many Unit 2 algorithms iterate through its characters using indices.

19
New cards

String.length()

Returns the number of characters in a string; the last valid index is length() - 1.

20
New cards

String.charAt(int index)

Returns the character at the given index; throws StringIndexOutOfBoundsException if index is not in 0..length()-1.

21
New cards

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.

22
New cards

String immutability

The property that strings cannot be changed in place; any modification creates a new string (e.g., building a result via concatenation).

23
New cards

String.equals(String other)

Compares string contents for equality; preferred over == for checking if two strings have the same characters.

24
New cards

StringIndexOutOfBoundsException

A runtime error caused by accessing invalid string indices (e.g., calling charAt(length()) or substring past the end).

25
New cards

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).

Explore top notes

note
RIse of Democracy Vocab Pt. 3
Updated 1507d ago
0.0(0)
note
KOREAN - IMPORTANT VOCABULARY
Updated 1262d ago
0.0(0)
note
Indirect Values
Updated 1507d ago
0.0(0)
note
biology
Updated 1941d ago
0.0(0)
note
Factorisation (copy)
Updated 1081d ago
0.0(0)
note
Chapter 9 - Jacksonian Era
Updated 1444d ago
0.0(0)
note
Hello
Updated 1195d ago
0.0(0)
note
RIse of Democracy Vocab Pt. 3
Updated 1507d ago
0.0(0)
note
KOREAN - IMPORTANT VOCABULARY
Updated 1262d ago
0.0(0)
note
Indirect Values
Updated 1507d ago
0.0(0)
note
biology
Updated 1941d ago
0.0(0)
note
Factorisation (copy)
Updated 1081d ago
0.0(0)
note
Chapter 9 - Jacksonian Era
Updated 1444d ago
0.0(0)
note
Hello
Updated 1195d ago
0.0(0)

Explore top flashcards

flashcards
faf
40
Updated 965d ago
0.0(0)
flashcards
faf
40
Updated 965d ago
0.0(0)