Aller au contenu
Examens 2027-2028 : Places DisponiblesPostuler
ITMagicITMagicAcademy
Ressources AP
APInformatiqueCSP

Algorithms & Pseudocode

AP Computer Science Principles — algorithms and the three building blocks (sequencing, selection, iteration) using College Board exam-reference pseudocode. Worked example and exam tip.

An algorithm is a finite set of instructions that accomplishes a task. Every algorithm — no matter how complex — is built from just three control structures. AP CSP uses College Board exam-reference pseudocode, so learn its notation.

The three building blocks

  1. Sequencing — steps run in order, top to bottom.
  2. Selection — a decision with IF / ELSE.
  3. Iteration — repetition with REPEAT n TIMES or REPEAT UNTIL (condition).

Exam-reference pseudocode

  • Assignment uses a left arrow: a ← 5
  • Output: DISPLAY(expression) Input: INPUT()
  • MOD gives the remainder: 7 MOD 3 is 1

```

total ← 0

REPEAT 5 TIMES

{

total ← total + 2

}

DISPLAY(total)

```

This displays 10.

Selection example

```

IF (score ≥ 60)

{ DISPLAY("Pass") }

ELSE

{ DISPLAY("Fail") }

```

Worked example

What does n MOD 2 = 0 test? It is true when n is even (remainder 0 when divided by 2) — a very common CSP pattern.

Exam tip

You must be able to trace pseudocode by hand and predict the output, and recognise when two algorithms are equivalent. Watch loop counts carefully (REPEAT 5 TIMES runs exactly 5 times). Also know linear vs binary search and that some problems are "undecidable" or only solvable in reasonable (polynomial) vs unreasonable (exponential) time.

Courte vidéo de cours

La vidéo de cours de ce sujet sera ajoutée bientôt.

Examen blanc

L'examen blanc de ce sujet sera ajouté bientôt.

Quiz d'entraînement

Teste-toi : résultats et explications immédiats.

  1. 1. Starting with total ← 0, what does REPEAT 5 TIMES { total ← total + 2 } display?

  2. 2. The condition n MOD 2 = 0 is true when n is:

  3. 3. The three building blocks of every algorithm are:

Besoin d'aide sur ce sujet ?

Lors d'un appel de découverte gratuit de 30 minutes, nous évaluons ton niveau et construisons un plan d'étude sur mesure.

Appel de découverte gratuit