← 返回资讯屏轩教育 · 行业资讯

A Guide to Standard Problem-Solving Methods in Algorithm Design | 算法设计中的标准解题方法指南

2026-08-30 14:29 · 本文部分内容由AI辅助创作

📚 A Guide to Standard Problem-Solving Methods in Algorithm Design | 算法设计中的标准解题方法指南

Algorithm design is a core skill in computer science, especially for students preparing for CIE examinations. This guide introduces the standard problem-solving methods you will need to master: decomposition, abstraction, pattern recognition, algorithms, and the key design approaches such as iteration, recursion, and divide-and-conquer.

算法设计是计算机科学的核心技能,尤其对于备考 CIE 的学生而言。本指南将介绍你需要掌握的标准解题方法:分解、抽象、模式识别、算法,以及迭代、递归、分治等关键设计方法。


1. Understanding the Problem | 理解问题

Before writing any code, you must fully understand the problem. This means identifying the inputs, the expected outputs, the constraints, and any special cases. Read the question carefully and underline keywords such as 'maximum', 'minimum', 'sorted', 'unique', or 'efficient'.

在编写任何代码之前,你必须充分理解问题。这包括识别输入、预期输出、约束条件以及任何特殊情况。仔细阅读题目,并在“最大值”“最小值”“已排序”“唯一”或“高效”等关键词下划线。

A common mistake is to start coding immediately. Instead, restate the problem in your own words. Ask yourself: What data do I have? What transformation is required? What should the output look like?

一个常见错误是立即开始编码。相反,你应该用自己的话重述问题。问自己:我有什么数据?需要进行什么转换?输出应该是什么样子?


2. Decomposition | 分解

Decomposition is the process of breaking a complex problem into smaller, more manageable sub-problems. Each sub-problem can be solved independently, and the solutions are combined to solve the original problem.

分解是将一个复杂问题拆分为更小、更易管理的子问题的过程。每个子问题可以独立求解,再将解合并以解决原始问题。

For example, writing a program to calculate student grades might be decomposed into: read data, calculate average, determine grade, and display results. Each part becomes a separate function or procedure.

例如,编写一个计算学生成绩的程序可以分解为:读取数据、计算平均分、确定等级和显示结果。每个部分成为一个独立的函数或过程。


3. Abstraction | 抽象

Abstraction means removing unnecessary details and focusing only on the essential features of a problem. In algorithm design, abstraction allows you to create a general solution that can be applied to many different situations.

抽象意味着去除不必要的细节,只关注问题的本质特征。在算法设计中,抽象使你能够创建适用于许多不同情况的通用解决方案。

For instance, when designing a sorting algorithm, you do not need to know whether the items are names, numbers, or records. You only need to know that they can be compared using a 'less than' operation.

例如,在设计排序算法时,你不需要知道排序对象是姓名、数字还是记录。你只需要知道它们可以通过“小于”操作进行比较。


4. Pattern Recognition | 模式识别

Pattern recognition is the ability to identify similarities and regularities in data or in problems. Recognising a pattern allows you to reuse a known solution instead of inventing a new one.

模式识别是识别数据或问题中相似性和规律性的能力。识别出模式可以让你复用已知的解决方案,而不是重新发明一个。

Common patterns in algorithm design include: searching, sorting, counting, aggregating, and transforming. If a problem asks for the largest value in a list, you immediately recognise the 'find maximum' pattern.

算法设计中常见的模式包括:搜索、排序、计数、聚合和转换。如果问题要求列表中的最大值,你可以立即识别出“查找最大值”模式。


5. Standard Algorithms: Searching | 标准算法:查找

Searching is the process of finding a specific element in a data structure. The two most common search algorithms are linear search and binary search.

查找是在数据结构中寻找特定元素的过程。两种最常见的查找算法是线性查找和二分查找。

Linear search works on any list and checks each element in order until the target is found or the list ends. Its time complexity is O(n) in the worst case.

线性查找适用于任何列表,按顺序检查每个元素,直到找到目标或列表结束。其最坏时间复杂度为 O(n)。

Binary search requires a sorted list. It repeatedly compares the target to the middle element and discards half of the remaining data. Its time complexity is O(log n).

二分查找要求列表已排序。它反复将目标与中间元素比较,并丢弃剩余数据的一半。其时间复杂度为 O(log n)。

Linear Search: O(n) | Binary Search: O(log n)

线性查找:O(n) | 二分查找:O(log n)


6. Standard Algorithms: Sorting | 标准算法:排序

Sorting arranges data in a specific order, usually ascending or descending. CIE examinations often focus on bubble sort and insertion sort for understanding, and may mention merge sort or quick sort for more advanced contexts.

排序是按特定顺序(通常升序或降序)排列数据。CIE 考试通常侧重冒泡排序和插入排序的理解,并可能在更高级的情境中提及归并排序或快速排序。

Bubble sort repeatedly steps through the list, compares adjacent items, and swaps them if they are in the wrong order. This process repeats until no swaps are needed.

冒泡排序重复遍历列表,比较相邻项目,如果顺序错误则交换。此过程重复进行,直到不再需要交换。

Insertion sort builds the sorted list one item at a time. Each new element is inserted into its correct position among the previously sorted elements.

插入排序一次一个地构建有序列表。每个新元素被插入到之前已排序元素中的正确位置。

Algorithm | 算法 Best Case | 最佳情况 Average Case | 平均情况 Worst Case | 最坏情况
Bubble Sort | 冒泡排序 O(n) O(n²) O(n²)
Insertion Sort | 插入排序 O(n) O(n²) O(n²)
Merge Sort | 归并排序 O(n log n) O(n log n) O(n log n)

广告 / Sponsored

7. Algorithm Design Techniques: Iteration | 算法设计技术:迭代

Iteration is the repeated execution of a block of code using a loop. In pseudocode, this is often represented by FOR, WHILE, or REPEAT structures.

迭代是使用循环重复执行一段代码。在伪代码中,通常用 FOR、WHILE 或 REPEAT 结构表示。

Iteration is appropriate when the number of repetitions is known (FOR loop) or when the loop must continue until a condition changes (WHILE loop).

当重复次数已知时(FOR 循环)或当循环必须继续直到条件改变时(WHILE 循环),迭代是合适的。

FOR i ← 1 TO n DO ... ENDFOR

FOR i ← 1 TO n DO ... ENDFOR


8. Algorithm Design Techniques: Recursion | 算法设计技术:递归

Recursion is a technique in which a function calls itself to solve a smaller version of the original problem. Every recursive function must have a base case to stop the recursion and a recursive case to continue it.

递归是一种函数调用自身以解决原始问题更小版本的技术。每个递归函数必须有一个基础情形来停止递归,以及一个递归情形来继续递归。

A classic recursive example is calculating the factorial of a number:

一个经典的递归示例是计算数字的阶乘:

ION Factorial(n) IF n = 0 THEN RETURN 1 ELSE RETURN n × Factorial(n − 1) ENDIF ENDFUNCTION

函数 Factorial(n) 如果 n = 0 则返回 1 否则返回 n × Factorial(n − 1) 结束 结束函数


9. Divide and Conquer | 分治法

Divide and conquer is a powerful design strategy that splits a problem into smaller independent sub-problems, solves each recursively, and combines the solutions. Merge sort is a typical example.

分治是一种强大的设计策略,它将问题拆分为更小的独立子问题,递归地解决每个子问题,然后合并解决方案。归并排序是一个典型例子。

Steps of divide and conquer:

分治法的步骤:

The time complexity of merge sort is O(n log n), which makes it significantly faster than bubble sort for large datasets.

归并排序的时间复杂度为 O(n log n),这使得它在大规模数据集上明显快于冒泡排序。


10. Greedy Algorithms | 贪心算法

A greedy algorithm makes the locally optimal choice at each step, hoping to find the global optimum. Greedy methods are simple and efficient, but they do not always produce the best solution for every problem.

贪心算法在每一步做出局部最优选择,希望找到全局最优解。贪心方法简单高效,但并不总是为每个问题产生最佳解决方案。

A classic greedy example is the coin change problem: to make a given amount using the fewest coins, always take the largest coin that does not exceed the remaining amount.

一个经典的贪心示例是找零问题:要用最少的硬币凑出给定金额,始终取不超过剩余金额的最大硬币。


11. Dynamic Programming | 动态规划

Dynamic programming (DP) solves problems by breaking them into overlapping sub-problems and storing the results of these sub-problems to avoid redundant computation. It is often used for optimisation problems.

动态规划通过将问题拆分为重叠子问题并存储这些子问题的结果来避免重复计算。它常用于最优化问题。

The Fibonacci sequence is a simple illustration. Without DP, computing Fibonacci(n) recursively repeats many calculations. With DP, each value is computed once and reused.

斐波那契数列是一个简单示例。不使用动态规划时,递归计算 Fibonacci(n) 会重复许多计算。使用动态规划时,每个值只计算一次并复用。

Fib(0) = 0, Fib(1) = 1, Fib(n) = Fib(n − 1) + Fib(n − 2)

Fib(0) = 0,Fib(1) = 1,Fib(n) = Fib(n − 1) + Fib(n − 2)


12. Comparing Problem-Solving Methods | 标准解题方法对比

When choosing a method, consider the problem size, whether the data is sorted, whether an exact answer is required, and how much memory is available.

选择方法时,要考虑问题规模、数据是否已排序、是否需要精确答案,以及可用内存有多少。

Method | 方法 Typical Use | 典型用途 Complexity | 复杂度
Iteration | 迭代 Simple repeated tasks O(n) or O(n²)
Recursion | 递归 Dividing problems naturally Depends on depth | 取决于深度
Divide and Conquer | 分治 Sorting, searching O(n log n)
Greedy | 贪心 Optimisation with local choices Often O(n log n)
Dynamic Programming | 动态规划 Overlapping sub-problems O(n²) or O(n·m)

In the CIE examination, always show your working clearly. Write pseudocode that matches the standard notation used in your syllabus, label each section of your algorithm, and state the complexity explicitly when asked.

在 CIE 考试中,始终清晰地展示你的步骤。编写与教学大纲中标准记法一致的伪代码,标注算法的每个部分,并在被问及时明确说明复杂度。


Published by TutorHao | Computer Science Revision Series | aleveler.com

广告 / Sponsored
现货 Cambridge International AS & ALevel IT Coursebook剑桥国际IGC…
计算机 备考教辅 · 正版现货 · 与本文内容相关
查看详情 / View on Taobao参考价 ¥467.0

更多咨询请联系16621398022(同微信)

备考资讯每日更新,关注不错过
考纲变化 · 科目分析 · 学习方法
扫码关注公众号 tutorhao
在微信里长按二维码识别关注
或截图后用「扫一扫 → 相册」选择本图
公众号:tutorhao