0Still learning
Know0
Define algorithm.
An algorithm is a finite set of instructions that, when followed in order, accomplish a specific task.

Join for free to unlock a full flashcard set, track what you know,
and turn revision into real progress.
What does it mean for an algorithm to be finite?
A finite algorithm must eventually reach an end; it cannot run forever.
Name the three building blocks of every algorithm.
The three building blocks are sequencing, selection, and iteration.
Was this flashcard helpful?
Define algorithm.
An algorithm is a finite set of instructions that, when followed in order, accomplish a specific task.
What does it mean for an algorithm to be finite?
A finite algorithm must eventually reach an end; it cannot run forever.
Name the three building blocks of every algorithm.
The three building blocks are sequencing, selection, and iteration.
Define sequencing.
Sequencing is executing steps one after another in a specific order.
Define selection.
Selection is making a decision based on a condition.
Define algorithm implementation.
Algorithm implementation is translating an algorithm into working code in a programming language.
Name three ways an algorithm can be expressed before it is turned into code.
An algorithm can be expressed in natural language, as a flowchart, or in pseudocode.
True or False?
Natural language is the most precise way to express an algorithm.
False.
Natural language is the easiest to understand but the least precise.
__________ is the closest to actual code and the most useful for algorithm implementation.
Pseudocode is the closest to actual code and the most useful for algorithm implementation.
Which way of expressing an algorithm shows decision points and branching logic most clearly?
A flowchart shows decision points and branching logic most clearly.
"If the temperature is below 0, display Freezing." Which algorithm building block is this?
This is selection, because a decision is made based on a condition.
"Keep asking for a password until the correct one is entered." Which algorithm building block is this?
This is iteration, because steps are repeated until a condition is met.
Define sequential execution.
Sequential execution is carrying out statements one at a time, in the order they appear, from top to bottom.
True or False?
Changing the order of statements cannot change a program's behavior.
False.
The execution order directly determines what the program does, so reordering statements can change its behavior entirely.
In what order must input, processing, and output happen in a program?
Inputs must be collected before they are processed, and processing must happen before output is displayed.
Define expression.
An expression is a combination of values, variables, and operators that is evaluated to produce a single value.
What value does 10 + 3 * 2 evaluate to?
10 + 3 * 2 evaluates to 16, because multiplication is performed before addition.
What determines the order in which the parts of an expression are evaluated?
The rules of precedence determine the order in which the parts of an expression are evaluated.
What value is displayed when this code segment runs?
n ← 2
n ← n * 5
n ← n - 3
DISPLAY(n)The code segment displays 7: n becomes 2, then 10, then 7.
Define code clarity.
Code clarity means the purpose of each section of code is easy to understand.
Name two ways to improve the readability of code.
Readability is improved by meaningful variable names, consistent formatting, and logical organization.
What should each statement in readable code be focused on?
Each statement in readable code should be focused on a single action.
Following best practices makes code easier for others to read, _____, and maintain.
Following best practices makes code easier for others to read, debug, and maintain.
Name the five arithmetic operators in AP CSP pseudocode.
The five arithmetic operators are +, -, *, /, and MOD.
Define the MOD operator.
The MOD operator returns the remainder after division.
What is the value of 23 MOD 4?
23 MOD 4 evaluates to 3, the remainder when 23 is divided by 4.
What is the value of 9 / 2 in AP CSP pseudocode?
9 / 2 evaluates to 4.5, because division gives a real number result.
True or False?
n MOD 2 returns 0 when n is odd.
False.
n MOD 2 returns 0 for even numbers and 1 for odd numbers.
Name two common uses of the MOD operator.
MOD is used for checking whether a number is even or odd, cycling through a fixed range of values, and extracting individual digits.
Define precedence.
Precedence determines the order of operations when an expression contains multiple operators.
What is the order of precedence for arithmetic operators?
The order of precedence is parentheses first, then multiplication, division, and MOD, then addition and subtraction.
Operators with equal precedence are evaluated from ____ to _____.
Operators with equal precedence are evaluated from left to right.
What is the value of 2 + 5 * 3?
2 + 5 * 3 evaluates to 17, because multiplication happens first (5 * 3 = 15).
What is the value of (2 + 5) * 3?
(2 + 5) * 3 evaluates to 21, because the parentheses are evaluated first (2 + 5 = 7).
What is the value of 14 MOD 4 * 3?
14 MOD 4 * 3 evaluates to 6: MOD and * have equal precedence, so 14 MOD 4 = 2 first, then 2 * 3 = 6.
By signing up you agree to our Terms and Privacy Policy