📚 Algorithm Design and Problem Solving | 算法设计与问题求解
Algorithms are the foundation of all computer programs. In Cambridge IGCSE Computer Science, algorithm design means creating a clear, step-by-step plan to solve a problem before any code is written. This topic covers pseudocode, flowcharts, sequence, selection, iteration, trace tables, test data, validation, verification and standard searching and sorting methods.
算法是所有计算机程序的基础。在剑桥 IGCSE 计算机科学中,算法设计意味着在编写任何代码之前,创建一个清晰、逐步的问题解决方案。本主题涵盖伪代码、流程图、顺序、选择、迭代、跟踪表、测试数据、验证、确认以及标准搜索和排序方法。
1. What Is an Algorithm? | 什么是算法?
An algorithm is a finite sequence of well-defined, step-by-step instructions that takes an input, processes it and produces an output. It must be precise enough for a human or computer to follow without ambiguity.
算法是一组有限、定义明确的逐步指令,它接受输入、处理输入并产生输出。它必须足够精确,使人类或计算机能够无歧义地执行。
A recipe, a bus timetable lookup and a login check can all be described as algorithms. In computing, algorithms are written in pseudocode or drawn as flowcharts before being translated into a programming language.
菜谱、公交时刻查询和登录检查都可以描述为算法。在计算中,算法在翻译成编程语言之前,先用伪代码编写或绘制成流程图。
2. Core Properties of an Algorithm | 算法的核心性质
A valid algorithm should be clear, finite, effective and complete. Every step must be defined well enough to be carried out, and the algorithm must stop after a limited number of steps.
有效的算法应当清晰、有限、有效且完整。每一步都必须定义得足够清楚以便执行,并且算法必须在有限步骤后停止。
Definiteness means each step says exactly what to do. Finiteness means the algorithm always terminates. Input and output mean it consumes data and produces a result. Effectiveness means every operation is basic enough to be performed.
确定性意味着每一步都准确说明要做什么。有限性意味着算法总会终止。输入和输出意味着它消费数据并产生结果。有效性意味着每个操作都足够基本,可以被执行。
If a set of instructions never stops, such as a music player loop that never ends, it is not an algorithm for solving a finite problem.
如果一组指令永不停止,例如一个永不结束的音乐播放器循环,那么它就不是解决有限问题的算法。
3. Pseudocode Conventions | 伪代码约定
Pseudocode is a compact, language-independent way to plan an algorithm. It uses keywords such as INPUT, OUTPUT, IF, THEN, ELSE, ENDIF, CASE OF, FOR, TO, NEXT, WHILE, DO, ENDWHILE, REPEAT and UNTIL.
伪代码是一种紧凑的、与语言无关的算法规划方式。它使用 INPUT、OUTPUT、IF、THEN、ELSE、ENDIF、CASE OF、FOR、TO、NEXT、WHILE、DO、ENDWHILE、REPEAT 和 UNTIL 等关键字。
Assignment is written with a left arrow: total ← total + 1. Input and output are written as INPUT number and OUTPUT result. This makes the logic easy to read and convert into Python, Java or Visual Basic.
赋值用左箭头表示:total ← total + 1。输入和输出写成 INPUT number 和 OUTPUT result。这样使逻辑易于阅读,也便于转换成 Python、Java 或 Visual Basic。
Example: a program to double a number.
示例:一个将数字加倍的算法。
INPUT n
result ← n × 2
OUTPUT result
4. Flowcharts | 流程图
A flowchart uses standard symbols to represent an algorithm visually. Ovals show start and end, parallelograms show input and output, rectangles show processes, and diamonds show decisions.
流程图使用标准符号直观表示算法。椭圆形表示开始和结束,平行四边形表示输入和输出,矩形表示处理,菱形表示判断。
Arrows connect the symbols and show the order of execution. A decision diamond usually has two outgoing arrows labelled TRUE or FALSE, or YES and NO.
箭头连接各个符号并显示执行顺序。判断菱形通常有两条输出箭头,标注为 TRUE 或 FALSE,或 YES 和 NO。
| Symbol | Meaning |
|---|---|
| Oval | Start or end |
| Parallelogram | Input or output |
| Rectangle | Process |
| Diamond | Decision |
| Arrow | Direction of flow |
This table shows the five flowchart symbols you must recognise in the Cambridge IGCSE examination.
上表列出了剑桥 IGCSE 考试中必须识别的五种
Published by TutorHao | IGCSE Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply