Algorithm Expression (College Board AP® Computer Science Principles): Study Guide
Algorithm fundamentals
What is an algorithm?
An algorithm is a set of finite instructions that, when followed in order, accomplish a specific task
Finite means the algorithm must eventually reach an end; it cannot run forever
Every algorithm is constructed from three fundamental building blocks:
Sequencing: executing steps one after another in a specific order
Selection: making a decision based on a condition (e.g. IF a score is above 50, display "Pass")
Iteration: repeating a set of steps until a condition is met (e.g. REPEAT UNTIL all items have been checked)
These three components can be combined to structure any algorithm, regardless of complexity
Algorithm implementation is the process of translating an algorithm into working code in a programming language
Algorithms can be expressed in several ways before being turned into code:
Representation | Description | Best used for |
|---|---|---|
Natural language | Steps written in everyday words | Explaining an algorithm to a non-technical audience |
Flowchart diagram | Visual chart using shapes and arrows to show the flow of steps | Showing decision points and branching logic clearly |
Pseudocode | Structured text that resembles code but is language-independent | Planning the logic before writing actual code |
Natural language example
1. Ask the user to enter a number
2. Divide the number by 2 and check the remainder
3. If the remainder is 0, display "Even"
4. Otherwise, display "Odd"
Flowchart diagram example

Pseudocode example
number ← INPUT()
IF (number MOD 2 = 0)
{
DISPLAY("Even")
}
ELSE
{
DISPLAY("Odd")
}
All three representations describe the same algorithm; only the format changes
Natural language is the easiest to understand but the least precise
Pseudocode is the closest to actual code and the most useful for algorithm implementation
Examiner Tips and Tricks
When the AP exam describes a process and asks you to identify the algorithm or its components, look for the three building blocks: sequencing (steps in order), selection (a decision or condition), and iteration (repetition). Most exam questions about algorithms test whether you can recognize which building block is being used in a given scenario.
For the AP Create Performance Task, you must include sequencing, selection, and iteration in your program — being able to identify these in your own code is essential for the written responses.
Worked Example
A teacher describes the following process: "Look at each student's test score. If the score is 90 or above, add the student's name to the honor roll list. Repeat this for every student in the class."
Which algorithm building blocks are used in this process?
(A) Sequencing only
(B) Selection and iteration only
(C) Sequencing, selection, and iteration
(D) Iteration only
[1]
Answer:
(C) Sequencing, selection, and iteration [1 mark]
The process sequences steps in order, uses selection to check each score against the 90 threshold, and uses iteration to repeat for every student; all three building blocks are present
Unlock more, it's free!
Was this revision note helpful?