Skip to main content
United StatesComputer Science PrinciplesSyllabus dot point

What is an algorithm, and how are sequencing, selection and iteration combined to solve problems?

Topic 3.9 Developing Algorithms: an algorithm is a finite set of instructions that accomplishes a task, built by combining sequencing, selection and iteration, and different algorithms can solve the same problem.

A focused answer to AP CSP Topic 3.9, covering what an algorithm is, the three building blocks (sequencing, selection, iteration), expressing algorithms in pseudocode and language, that different algorithms can solve the same problem, and standard list algorithms.

Generated by Claude Opus 4.810 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this topic is asking
  2. What an algorithm is
  3. The three building blocks
  4. Different algorithms, same problem
  5. Standard list algorithms
  6. Try this

What this topic is asking

The College Board (Topic 3.9) wants you to develop algorithms: design and express the step-by-step logic that solves a problem. Every algorithm is built from three building blocks: sequencing (steps in order), selection (conditionals) and iteration (loops). You must combine these to solve problems, express algorithms in pseudocode, and understand that different algorithms can solve the same problem (and may differ in clarity or efficiency).

What an algorithm is

The three building blocks

For example, "count the even numbers in a list" uses sequencing (set up a counter, then loop, then display), iteration (loop over the list) and selection (test each value).

Different algorithms, same problem

A single problem usually has many correct algorithms. To find the largest value in a list you could scan once tracking the maximum, or sort the list and take the last element. Both work; they differ in how much work they do. The CED wants you to recognize that algorithms can be compared for correctness, clarity and efficiency (see algorithmic efficiency).

Standard list algorithms

Several patterns recur and are worth knowing cold:

  • Sum / count: traverse, accumulate a running total or counter.
  • Maximum / minimum: traverse, keep the best value seen so far (initialised to the first element).
  • Search: traverse, check each element against a target, report found or not found.

Try this

Q1. Name the three building blocks of algorithms. [3 points]

  • Cue. Sequencing (steps in order), selection (conditionals), and iteration (loops).

Q2. Explain what it means that different algorithms can solve the same problem. [2 points]

  • Cue. A problem can have several correct step-by-step solutions; they may differ in clarity or efficiency but all produce the right result, for example finding a maximum by scanning versus by sorting.

Exam-style practice questions

Practice questions written in the style of College Board exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

AP 2022 (style)1 marksMultiple choice. Which of the following best describes an algorithm? (A) A single instruction that runs once. (B) A finite set of instructions that accomplishes a specific task. (C) A list of data values with no instructions. (D) A programming language.
Show worked answer β†’

The answer is (B).

An algorithm is a finite sequence of instructions that, when followed, accomplishes a specific task or solves a problem. (A) is too narrow; algorithms usually combine many steps. (C) describes data, not a procedure. (D) a language is the medium you express an algorithm in, not the algorithm itself.

Markers reward the definition: a finite set of clear instructions that accomplishes a task.

AP 2021 (style)3 marksFree response (code writing). Write AP CSP pseudocode that counts how many even numbers are in a list `nums` and displays the count.
Show worked answer β†’

A 3-point question combining iteration, selection and the MOD operator.

evens ← 0
FOR EACH n IN nums
{
  IF (n MOD 2 = 0)
  {
    evens ← evens + 1
  }
}
DISPLAY(evens)

Point 1: initialise the counter evens to 0. Point 2: traverse the list (iteration) and test each value with n MOD 2 = 0 (selection plus MOD) to detect even numbers. Point 3: increment the counter and display it after the loop. This algorithm combines sequencing, selection and iteration, the three building blocks. A common error is using n / 2 = 0 instead of n MOD 2 = 0.

Related dot points

Sources & how we know this