A Adam Learning
Back to notes
9618-AS-11-02Chapter 11Section 11.2short-answer

11.2 Constructs 程序结构简答

Review the exact wording students need for this knowledge point, then open a filtered question list when ready to practise.

Find questions for 9618-AS-11-02

Scope

本页重点是选择并 justify loop/construct。IF、CASE、FOR、WHILE、REPEAT 完整语法留到代码专项。

Selection

  • IF selects between paths based on Boolean condition;nested IF handles dependent decisions。
  • CASE selects one branch from multiple discrete values and is clearer than a long chain of equality tests。

Loop structures

Count-controlled loop

Use when the number of iterations is known before the loop starts,例如 processing every element in a fixed-size array or repeating exactly 50 times。

Pre-condition loop

Condition is tested before the body, so it may execute zero times。Use when continuation/termination depends on a condition that must be checked first。

Post-condition loop

Condition is tested after the body, so it executes at least once。Use when input/process must occur once before the stopping condition can be known。

Justification patterns

Use a count-controlled loop because the number of iterations is known: it repeats once for each character in the string.
Use a conditional loop because the number of iterations is not known and the loop ends when a sentinel value is input.
Use a conditional loop so the search can terminate as soon as the first match is found, avoiding unnecessary iterations.

第一分给 structure name,第二分给 scenario-specific reason。

Efficiency

An efficient loop avoids unnecessary work:

  • Stop searching after a required item is found。
  • Do not repeatedly call a function whose inputs have not changed。
  • Use a known count rather than repeatedly checking an expensive condition when appropriate。
  • Avoid processing data after the result is already determined。

Exam checklist

  • Iteration count 是否已知?
  • Loop body 是否必须至少运行一次?
  • 是否需要 sentinel/EOF/match 控制停止?
  • Justification 是否联系具体 data/condition?
  • 是否可 early exit 减少重复处理?

完整 selection 与 iteration pseudocode 留到专项练习。

Practice This Knowledge Point

Open the question bank with this knowledge code already filled in. The filtered list will show matching questions for this note.

Open filtered practice
Source questions used