Developing Algorithms · 开发算法
| English | 中文 | Pinyin · 拼音 |
|---|---|---|
| algorithm/ˈælɡərɪθəm/ | 算法 | suàn fǎ |
| finite/ˈfaɪnaɪt/ | 有限的 | yǒu xiàn de |
| sequencing/ˈsiːkwənsɪŋ/ | 顺序 | shùn xù |
| flowchart/ˈfləʊtʃɑːt/ | 流程图 | liú chéng tú |
| natural language/ˈnætʃərəl ˈlæŋɡwɪdʒ/ | 自然语言 | zì rán yǔ yán |
| same result/seɪm rɪˈzʌlt/ | 相同结果 | xiāng tóng jié guǒ |
| refine/rɪˈfaɪn/ | 改进 | gǎi jìn |
| efficient/ɪˈfɪʃənt/ | 高效 | gāo xiào |
What is an algorithm?
- An algorithm 算法 is a finite 有限的, step-by-step set of instructions to complete a task.
- "Finite" means it always ends after a limited number of steps.
- A recipe, a route to school, and a sorting method are all algorithms.
- Every program is built from algorithms.
什么是算法?
- 一个算法(algorithm)是一个有限的(finite)、分步的指令集合,用来完成一个任务。
- "有限"意味着它总在有限数量的步骤后结束。
- 一份食谱、一条去学校的路线、一种排序方法都是算法。
- 每个程序都由算法构建。
An algorithm is: · 一个算法是:
"Finite" means it always ends after a limited number of steps. · "有限"意味着它总在有限步骤后结束。
Three building blocks
- Every algorithm can be built from three basic structures:
- sequencing 顺序: doing steps one after another;
- selection: choosing between paths;
- iteration: repeating steps.
三个构件
- 每个算法都能由三个基本结构构建:
- 顺序(sequencing):一个接一个地做步骤;
- 选择:在路径间选择;
- 迭代:重复步骤。
Sequencing, selection, or iteration? · 顺序、选择,还是迭代?
Every algorithm is built from three structures: sequencing (steps in order), selection (choosing a path), and iteration (repeating steps). · 每个算法都由三个结构构建:顺序(按序的步骤)、选择(选一条路径)和迭代(重复步骤)。
Which are the three building blocks of algorithms? (Select all that apply) · 哪些是算法的三个构件?(选出所有正确项)
Sequencing, selection, and iteration build every algorithm. · 顺序、选择和迭代构建每个算法。
A flowchart, pseudocode, and natural language can all express: · 流程图、伪代码和自然语言都能表达:
All three describe the same steps differently. · 这三种以不同方式描述相同的步骤。
Two different algorithms can produce the same correct result, one faster than the other. · 两个不同的算法能产生相同的正确结果,一个比另一个快。
Neither is "more correct" if both give the right answer. · 如果两者都给出正确答案,谁也不"更正确"。
Ways to express it
- You can express an algorithm as pseudocode, as a flowchart 流程图 (boxes and arrows), or in plain natural language 自然语言.
- All three describe the same steps in different forms.
- Different algorithms can give the same result 相同结果 — one short but slow, another longer but fast.
- Neither is "more correct" if both give the right answer.
表达它的方式
- 你能把算法表达为伪代码、一个流程图(flowchart,方框和箭头),或用白话自然语言(natural language)。
- 这三种以不同形式描述相同的步骤。
- 不同的算法能给出相同结果(same result)——一个短但慢,另一个长但快。
- 如果两者都给出正确答案,谁也不"更正确"。
The "largest of three" algorithm runs on a=4, b=9, c=6. What does it output? · "三个中的最大"算法在 a=4、b=9、c=6 上运行。它输出什么?
Start 4; 9 > 4 → 9; 6 > 9 is false → stays 9. · 开始 4;9 > 4 → 9;6 > 9 为假 → 保持 9。
Improving an algorithm step by step to be correct, clear, and efficient is called . · 一步步改善算法,让它正确、清晰、高效,叫。
Refining follows testing, making the algorithm better each pass. · 改进跟在测试之后,每一遍让算法更好。
Refine for efficiency
- We refine 改进 an algorithm so it is correct, clear, and efficient 高效.
- Refining means improving it step by step after testing.
Largest of three. largest ← a; IF b > largest: largest ← b; IF c > largest: largest ← c; DISPLAY largest. For a=4, b=9, c=6: start 4; 9 > 4 → largest 9; 6 > 9 is false → stays 9. Output 9. This uses sequencing and selection.
为效率而改进
- 我们改进(refine)一个算法,让它正确、清晰、高效(efficient)。
- 改进意味着在测试后一步步改善它。
三个中的最大。 largest ← a;IF b > largest:largest ← b;IF c > largest:largest ← c;DISPLAY largest。对 a=4、b=9、c=6:开始 4;9 > 4 → largest 9;6 > 9 为假 → 保持 9。输出 9。这用了顺序和选择。
An algorithm is a finite set of steps, built from three structures: sequencing, selection, and iteration. You can express it as pseudocode, a flowchart, or natural language. Different algorithms can give the same result, so we refine them to be correct, clear, and efficient.
一个算法是一个有限的步骤集合,由三个结构构建:顺序、选择和迭代。你能把它表达为伪代码、一个流程图或自然语言。不同的算法能给出相同结果,所以我们改进它们,让它们正确、清晰、高效。