Appearance
3.9 Developing Algorithms 算法开发
The way statements are sequenced and combined in a program determines the computed result. Programs incorporate iteration and selection constructs to represent repetition and make decisions to handle varied input values.
- 程序中语句的排序和组合方式决定了计算结果。程序结合迭代和选择结构来表示重复并做出决策来处理各种输入值。
核心要点 Core Points
Algorithms can be created from an idea, by combining existing algorithms, or by modifying existing algorithms.
- 算法可以从一个想法创建,通过组合现有算法,或通过修改现有算法。
Knowledge of existing algorithms can help in constructing new ones. Some existing algorithms include:
- 现有算法的知识有助于构建新的算法。一些现有算法包括:
- determining the maximum or minimum value of two or more numbers
- 确定两个或多个数字的最大值或最小值
- computing the sum or average of two or more numbers
- 计算两个或多个数字的总和或平均值
- identifying if an integer is or is not evenly divisible by another integer
- 识别一个整数是否能被另一个整数整除
- determining a robot's path through a maze
- 确定机器人通过迷宫的路径
Using existing correct algorithms as building blocks for constructing another algorithm has benefits such as reducing development time, reducing testing, and simplifying the identification of errors.
- 使用现有的正确算法作为构建另一个算法的构建块具有好处,如减少开发时间、减少测试和简化错误识别。
Algorithms can be written in different ways and still accomplish the same tasks.
- 算法可以用不同的方式编写,但仍然完成相同的任务。
Algorithms that appear similar can yield different side effects or results.
- 看起来相似的算法可能产生不同的副作用或结果。
Some conditional statements can be written as equivalent Boolean expressions.
- 一些条件语句可以写成等价的布尔表达式。
Some Boolean expressions can be written as equivalent conditional statements.
- 一些布尔表达式可以写成等价的条件语句。
Different algorithms can be developed or used to solve the same problem.
- 可以开发或使用不同的算法来解决同一个问题。
学生活动 Student Activities
Create algorithms.
- 创建算法。
Combine and modify existing algorithms.
- 组合和修改现有算法。
Compare multiple algorithms to determine if they yield the same side effect or result.
- 比较多个算法以确定它们是否产生相同的副作用或结果。
