Computational thinking
引入
14:30
计算思维
这里有一个任务:构建一个系统来管理整家商店的库存——每种产品、每笔销售、每次送货、每份报告。作为一个整体问题,它太大以至于……
英文讲解 · 可切换中英文字幕
本课内容
| English | 释义 | 拼音 |
|---|---|---|
| computational thinking/ˌkɒmpjuːˈteɪʃənl ˈθɪŋkɪŋ/ | 计算思维 | jì suàn sī wéi |
| abstraction/əbˈstrækʃn/ | 抽象 | chōu xiàng |
| decomposition/ˌdiːkɒmpəˈzɪʃn/ | 分解 | fēn jiě |
| pattern recognition/ˈpætn ˌrekəɡˈnɪʃn/ | 模式识别 | mó shì shí bié |
| algorithms/ˈælɡərɪθəmz/ | 算法 | suàn fǎ |
| model/ˈmɒdl/ | 模型 | mó xíng |
| variable name | 变量名 | biàn liàng míng |
| memory address/ˈmeməri əˈdres/ | 内存地址 | nèi cún dì zhǐ |
| function/ˈfʌŋkʃn/ | 函数 | hán shù |
| block of code | 代码块 | dài mǎ kuài |
| class/klæs/ | 类 | lèi |
| attributes/ˈætrɪbjuːts/ | 属性 | shǔ xìng |
| module/ˈmɒdjuːl/ | 模块 | mó kuài |
| breaking a large problem into smaller sub-problems | 子问题 | zi wèn tí |
| sub-tasks | 子任务 | zi rèn wù |
| sub-problem/sʌb ˈprɒbləm/ | 子问题 | zi wèn tí |
| procedure/prəˈsiːdʒə/ | 过程 | guò chéng |
| sub-modules | 子模块 | zi mó kuài |
| library routine/ˈlaɪbrəri ruːˈtiːn/ | 库例程 | kù lì chéng |
| structure chart/ˈstrʌktʃə tʃɑːt/ | 结构图 | jié gòu tú |
| Algorithm design | 算法设计 | suàn fǎ shè jì |
一张故意"画错"的地图
- 1931 年,失业的绘图员 Harry Beck 重新绘制了伦敦地铁图。
- 他丢掉了真实的地理:每条线都画成直线,每个车站等距排列。
- 这张图是"错"的,却立刻更好用了。如今全世界的地铁图都在模仿它。
- Beck 只保留乘客需要的东西:车站,以及它们怎样连接。这就是计算机出现之前的计算思维(computational thinking)。

什么是计算思维
- 一套分析问题、并设计出计算机能运行的解决方案的思维工具。
- 大纲点名其中两个:抽象(abstraction)和分解(decomposition)。
- 另外两个为它们提供支持:模式识别(pattern recognition)和设计算法(algorithms)。
抽象
- 抽象是指保留一个问题的本质特征,并忽略无关的细节,得到一个更简单的模型。
- 地铁图保留车站和线路,丢掉地理信息。
- 变量名隐藏了内存地址;函数把一个代码块藏在一个名称后面;类只保留系统需要的属性。

抽象只保留问题的本质特征,去掉无关的细节
Abstraction means:
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
Abstraction simplifies a problem to its essentials. Breaking into parts is decomposition.
A train map that keeps the stations and lines but drops the real geography is an example of abstraction.
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
It keeps what matters (stations, connections) and discards the rest — exactly what abstraction does.
目的和好处
- 目的:得到一个更简单的问题模型,只包含解决问题所需的细节。
- 好处:问题更容易理解和编程;程序更小,编写和测试起来更快;同一个模型可以在类似的问题中复用。
- 考官会分别问目的和好处。两个都要记住。
Select 所有 the statements that are benefits of abstraction.
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
Abstraction drops detail, so keeping every detail is the opposite of it, and it says nothing about hardware. The three real benefits are understanding, size/speed of development, and reuse.
例题:一个抽象模型
- 一家咖啡店为每位会员卡顾客储存以下信息:编号、姓名、家庭住址、电子邮件地址、手机号码、出生日期、积分和上次到店日期。
- 一个新模块通过编号查找顾客,并向 30 天未到店的顾客发送个性化优惠券邮件。它需要哪些数据?
- 需要:编号(用于查找顾客)、电子邮件地址(用于发送邮件)、姓名(用于个性化邮件内容)、上次到店日期(用于筛选发送对象)。
- 不需要:家庭住址、手机号码、出生日期、积分。省略这些数据就是抽象。

The voucher-email module in the worked example needs which of these items? Select 所有 that apply.
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
Email to send to, date of last visit to choose who qualifies, and the ID to look the customer up. The postal address and birthday play no part in an email voucher, so an abstract model of this module leaves them out.
分解
- 分解是指把一个大问题拆成更小的子问题,每个子问题都更容易解决。
- 找到主要部分 → 把每个部分拆成子任务 → 直到每个子任务都小到能直接编码 → 解决并组合。
- 每个子问题成为一个程序模块:一个过程或一个函数。

把一个程序分解成模块和子模块
Decomposition means:
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
Decomposition splits a big task into smaller, separately-solvable sub-tasks.
Each sub-problem produced by decomposition becomes a program module: a procedure or a ____.
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
The syllabus wording is exact: decomposition leads to the concept of a program module — a procedure or a 功能.
例题:一个电影院订票程序
- 一家有多个放映厅的电影院想要一个让顾客订座位的程序。
- ShowFilms() 列出电影、放映厅和开场时间。
- ChooseSeats() 显示座位图,接收顾客的选择,并检查座位是否空闲。
- TakePayment() 计算价格,处理银行卡付款,并打印票。
- 三个模块,每一个都小到可以独立设计、编码和测试。

Match each part of the cinema booking design to what it is.
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
Three modules, each doing one job, and a structure chart to show how they fit together.
为什么要分解?三分的答案
- 每个子问题都小到可以独立设计、编码和测试。
- 不同的程序员可以同时处理不同的模块。
- 已经存在的模块或库例程可以复用;错误也更容易找到,因为它位于一个模块中。
- 表示分解的图叫作结构图(主题 12)。
四个基石
- 分解:把问题拆开。模式识别:发现什么在重复,让一个解决方案服务多个部分。
- 抽象:剥掉不重要的细节。算法设计:写出逐步的解决方案。
- 实际上你大致按这个顺序使用它们,而且会不止一轮。
Solving a problem the computational way
Step through the four cornerstones in the order you'd use them — break the problem down, spot what repeats, strip it to essentials, then write the steps.
Match each cornerstone of computational thinking to what it means.
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
The four cornerstones — decompose, spot patterns, abstract, then design the algorithm.
Put the computational-thinking steps in the order presented in the lesson.
难度 3/5 · 今日首次完成可获 200 金币及少量额外奖励
Break it down, find what repeats, strip to essentials, then write the steps.
别把它们弄混
- 抽象去掉细节;分解拆开问题。“拆成更小的部分”不是对抽象的描述。
- “描述”题的答案需要说明怎么做,而不是只写一个词:说清拆的是什么、拆成什么、每个部分变成什么。
- 把答案和情境联系起来。如果分解题的答案完全没有提到库存系统、电影院或商店,就会丢一分。

In a "describe decomposition" question, an answer that never mentions the scenario (the shop, the cinema) can still earn full marks.
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
Mark schemes cap a generic answer: the recent stock-control question said "max 2 if no mention of stock control". Name the scenario's own modules and data.
你掌握了
- 抽象 = 保留本质,忽略无关细节 → 一个更简单的模型
- 分解 = 把大问题拆成子问题 → 每个成为一个过程或函数
- 分解的好处:分开设计/编码/测试、分担工作、复用模块、更快找到错误
- 永远用情境自己的模块和数据来描述
出了什么问题?只有网站团队能看到这些信息。