B1.1.4 · Approaches to computational thinking
B1.1.4 · 计算思维的方法
Tracing Flowcharts
追踪流程图
A flowchart is an algorithm you can actually see: a diagram, built from a small set of standard shapes, that shows exactly what order a program's steps happen in, and exactly which path it takes when it hits a decision.
流程图是一种真正看得见的算法:一种由少量标准形状构成的图形,准确展示程序步骤发生的顺序,以及遇到判断时究竟会走哪条路径。
Explainer
讲解
By convention a flowchart's steps run downward the page, moving across into a new column only when the diagram genuinely needs one. All six standard symbols, at a glance:
按照惯例,流程图的步骤沿页面向下延伸,只有在图形确实需要时,才会横向移入新的一列。六种标准符号一览:
Worked example
示例讲解
Trace it yourself
自己动手追踪
A PE teacher wants to know how many of 5 students did 20 or more push-ups. The flowchart below reads each student's count in turn and keeps a running tally.
一位体育老师想知道 5 名学生中有多少人完成了 20 个或以上的俯卧撑。下面的流程图依次读取每名学生的次数,并持续累计计数。
Reads top to bottom: initialise, then loop while I < 5, reading one student's count each time.
从上到下阅读:先初始化,然后在 I < 5 时循环,每次读取一名学生的次数。
Before the loop starts: the two variables are initialised.
| I | PUSHUPS | COUNT |
|---|---|---|
| 0 | — | 0 |
Pass 1 (I = 0): is 0 < 5? Yes. Read the first student's count, 18. Is 18 ≥ 20? No, so COUNT doesn't change. I becomes 1.
| I | PUSHUPS | COUNT |
|---|---|---|
| 0 | — | 0 |
| 1 | 18 | 0 |
Pass 2 (I = 1): is 1 < 5? Yes. Read the second count, 22. Is 22 ≥ 20? Yes, so COUNT increases. I becomes 2.
| I | PUSHUPS | COUNT |
|---|---|---|
| 0 | — | 0 |
| 1 | 18 | 0 |
| 2 | 22 | 1 |
Pass 3 (I = 2): is 2 < 5? Yes. Read the third count, 25. Is 25 ≥ 20? Yes, so COUNT increases. I becomes 3.
| I | PUSHUPS | COUNT |
|---|---|---|
| 0 | — | 0 |
| 1 | 18 | 0 |
| 2 | 22 | 1 |
| 3 | 25 | 2 |
Pass 4 (I = 3): is 3 < 5? Yes. Read the fourth count, 15. Is 15 ≥ 20? No, so COUNT doesn't change. I becomes 4.
| I | PUSHUPS | COUNT |
|---|---|---|
| 0 | — | 0 |
| 1 | 18 | 0 |
| 2 | 22 | 1 |
| 3 | 25 | 2 |
| 4 | 15 | 2 |
Pass 5 (I = 4): is 4 < 5? Yes. Read the fifth count, 20. Is 20 ≥ 20? Yes (equal counts as meeting it), so COUNT increases. I becomes 5.
| I | PUSHUPS | COUNT |
|---|---|---|
| 0 | — | 0 |
| 1 | 18 | 0 |
| 2 | 22 | 1 |
| 3 | 25 | 2 |
| 4 | 15 | 2 |
| 5 | 20 | 3 |
Loop check (I = 5): is 5 < 5? No. The loop ends here, and the final value of COUNT is output.
| I | PUSHUPS | COUNT |
|---|---|---|
| 0 | — | 0 |
| 1 | 18 | 0 |
| 2 | 22 | 1 |
| 3 | 25 | 2 |
| 4 | 15 | 2 |
| 5 | 20 | 3 |
| Output | 3 | |
Check your understanding
Using the same flowchart, what is the value of COUNT immediately after the THIRD student's count (25) has been processed?
Common mistake
RecurringA genuinely documented pattern: candidates draw a decision diamond correctly, with two lines leaving it, but forget to label which line means Yes and which means No. Without that label, a marker (or anyone else reading the flowchart) has no way to tell which path the algorithm actually takes when the condition is met.
Two exits, neither labelled: Both lines leaving the decision diamond are drawn correctly, but neither says which answer sends the algorithm which way. A reader has to guess.
Every exit labelled: Both lines carry a clear "Yes" or "No" (or "True"/"False"), so exactly one path is possible to trace at that decision, no guessing required.
Revision questions
Past-paper style. Write an answer, then reveal the marking points and mark yourself.
[2]Identify the flowchart symbol used to represent a yes/no question, and the symbol used to represent the start of an algorithm.
Marking points
评分要点
- A decision (a yes/no question) is represented by a diamond.
- The start of an algorithm is represented by a rounded terminator shape.
- 判断(一个是/否问题)用菱形表示。
- 算法的开始用圆角的起止符形状表示。
[3]State one reason why every branch leaving a decision symbol must be labelled.
Marking points
评分要点
- Two lines leave the decision, one for yes and one for no, and they lead to different steps.
- Without labels a reader cannot tell which path the algorithm follows when the condition is true, so the flowchart cannot be traced unambiguously.
- 两条线离开判断符,一条表示是,一条表示否,它们通向不同的步骤。
- 没有标签,读者无法判断当条件为真时算法走哪条路径,所以流程图无法被无歧义地追踪。
[6]Trace the push-up counting flowchart above using the values 12, 20, 8, 30, 19 instead. Show the value of I, PUSHUPS and COUNT after each pass, and state the final output.
Marking points
评分要点
- Before the loop: I = 0, COUNT = 0.
- Pass 1: read 12; 12 >= 20 is No; COUNT stays 0; I becomes 1. (I = 1, PUSHUPS = 12, COUNT = 0)
- Pass 2: read 20; 20 >= 20 is Yes; COUNT becomes 1; I becomes 2. (I = 2, PUSHUPS = 20, COUNT = 1)
- Pass 3: read 8; 8 >= 20 is No; COUNT stays 1; I becomes 3. (I = 3, PUSHUPS = 8, COUNT = 1)
- Pass 4: read 30; 30 >= 20 is Yes; COUNT becomes 2; I becomes 4. (I = 4, PUSHUPS = 30, COUNT = 2)
- Pass 5: read 19; 19 >= 20 is No; COUNT stays 2; I becomes 5. (I = 5, PUSHUPS = 19, COUNT = 2)
- Loop check: 5 < 5 is No, so the loop ends. Final output: COUNT = 2.
- 循环前:I = 0,COUNT = 0。
- 第 1 轮:读入 12;12 >= 20 为否;COUNT 保持 0;I 变为 1。(I = 1,PUSHUPS = 12,COUNT = 0)
- 第 2 轮:读入 20;20 >= 20 为是;COUNT 变为 1;I 变为 2。(I = 2,PUSHUPS = 20,COUNT = 1)
- 第 3 轮:读入 8;8 >= 20 为否;COUNT 保持 1;I 变为 3。(I = 3,PUSHUPS = 8,COUNT = 1)
- 第 4 轮:读入 30;30 >= 20 为是;COUNT 变为 2;I 变为 4。(I = 4,PUSHUPS = 30,COUNT = 2)
- 第 5 轮:读入 19;19 >= 20 为否;COUNT 保持 2;I 变为 5。(I = 5,PUSHUPS = 19,COUNT = 2)
- 循环检查:5 < 5 为否,循环结束。最终输出:COUNT = 2。
Flashcards
Active recall for this statement’s key terms.
Keep this statement’s practice with you
Free account: unlock every revision question and flashcard for B1.1.4, and every other IB CS 2027 statement.