AP Computer Science A: Selection and Iteration

0.0(0)
studied byStudied by 1 person
0.0(0)
linked notesView linked note
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/28

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

29 Terms

1
New cards

Selection

A control structure that allows a program to choose between multiple execution paths based on boolean conditions.

2
New cards

Iteration

A programming technique that repeatedly executes a block of code while a condition is true

3
New cards

if Statement

Executes a block of code when the given condition evaluates to true.

4
New cards

if-else Statement

Executes one block if the condition is true, and another block if it is false.

5
New cards

Nested if

An if statement placed inside another to handle multiple conditions

6
New cards

switch Statement

A multi-way selection structure that executes code based on the value of an expression, often used with int, enum, or String types.

7
New cards

Boolean Expression

An expression that evaluates to either true or false, often using relational or logical operators.

8
New cards

Relational Operators

Operators that compare two values: ==, !=, >, <, >=, <=.

9
New cards

Logical Operators

Operators used to combine boolean expressions: && (and), || (or), ! (not).

10
New cards

Short-Circuit Evaluation

The process where logical expressions stop evaluating as soon as the result is determined (e.g., in &&, if left side is false, right side isn’t evaluated).

11
New cards

De Morgan’s Laws

Rules for negating boolean expressions:

!(A && B) → !A || !B, and !(A || B) → !A && !B.

12
New cards

Equality vs. Assignment

== tests equality, while = assigns a value. Using = in a condition is a logic error

13
New cards

.equals() Method

Compares object contents, not references (used for Strings or other objects)

14
New cards

Ternary Operator

A compact conditional expression in the form (condition ? trueValue : falseValue).

15
New cards

while Loop

A loop that tests its condition before executing its body; executes zero or more times.

16
New cards

do-while Loop

Executes the loop body once before checking the condition; always runs at least once.

17
New cards

for Loop

A counting loop with an initialization, condition, and update in a single line.

18
New cards

Enhanced for Loop

A simplified loop for iterating over arrays or collections (read-only access).

19
New cards

Loop Control Variable

A variable that controls the number of loop iterations, typically incremented or updated each pass.

20
New cards

break Statement

Exits the nearest enclosing loop immediately.

21
New cards

continue Statement

Skips the rest of the current iteration and moves to the next loop cycle

22
New cards

Infinite Loop

A loop that never terminates because its condition always remains true.

23
New cards

Sentinel-Controlled Loop

A loop that continues until a special value (sentinel) is encountered, often used with user input.

24
New cards

Counter-Controlled Loop

A loop that repeats a known number of times using a loop counter variable.

25
New cards

Accumulator Pattern

A loop pattern used to compute totals or sums by repeatedly adding values to a variable.

26
New cards

Nested Loop

A loop inside another loop; used for multi-dimensional data but increases time complexity (O(n²)).

27
New cards

Loop Invariant

A statement that is true before and after each loop iteration, useful for reasoning about loop correctness

28
New cards

Off-by-One Error

A common mistake in loops caused by incorrect boundary conditions (e.g., using < instead of <=)

29
New cards

Time Complexity

A measure of how loop execution time grows with input size; single loop = O(n), nested loop = O(n²).