İçeriğe atla
2027 - 2028 Sınavları için son kontenjanlarBaşvuru
ITMagicITMagicAcademy
AP kaynakları
APBilgisayar BilimiCSP

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.

Kısa Ders Videosu

Bu konunun ders videosu yakında eklenecek.

Deneme Sınavı

Bu konunun deneme sınavı yakında eklenecek.

Alıştırma Testi

Kendini dene: anında sonuç ve açıklama.

  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:

Bu konuda desteğe mi ihtiyacın var?

30 dakikalık ücretsiz tanışma görüşmesinde seviye belirlenir, kişiye özel bir çalışma planı kurulur.

Ücretsiz tanışma görüşmesi