1/9
CSA Runestone 2.6-2.9 Vocab
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
De Morgan's Law
Can be applied to Boolean expressions to create equivalent ones:
!(a && b) is equivalent to !a || !b
!(a || b) is equivalent to !a && !b
Negation
A negated expression with a relational operator can be simplified by flipping the relational operator to its opposite sign.
!(c == d) is equivalent to c != d
!(c != d) is equivalent to c == d
!(c < d) is equivalent to c >= d
!(c > d) is equivalent to c <= d
!(c <= d) is equivalent to c > d
!(c >= d) is equivalent to c < d
Aliases
When two object references reference the same object
While Loop
A type of iterative statement. The Boolean expression is evaluated before each iteration of the loop body, including the first. When the expression evaluates to true, the loop body is executed. This continues until the Boolean expression evaluates to false, whereupon the iteration terminates.
Loop Control Variable
Used in the boolean condition of the loop
Infinite Loop
occurs when the Boolean expression in an iterative statement always evaluates to true
Off by One Error
occur when the iteration statement loops one time too many or one time too few
Input Controlled Loops
Use a sentinel value that is input by the user like “bye” or -1 as the condition for the loop to stop
For Loop
Type of iterative statement. There are three parts: the initialization (of the loop control variable or counter), the Boolean expression (testing the loop variable), and the update (to change the loop variable).
Accumulator Pattern
An algorithm that involves storing and updating an accumulator value within a loop, for example to compute a sum or average of a set of values.