3.17 Algorithmic Efficiency
1. Exam Points
Heuristic(启发式算法).
Reasonable algorithms.
Unreasonable algorithms。
Analyze number of executions of given algorithms.
- Don’t miss some lines when analyzing number of executions.
2. Knowledge Points
(1) Algorithmic Efficiency
Efficiency is an estimation of the amount of computational resources used by an algorithm.
- Efficiency is typically expressed as a function of the size of the input (For example:the size of elements in a list).
- An algorithm’s
efficiency can be informally measured by determining the number of times a statement or group of statements executes.
- Algorithms with a
polynomial efficiency or slower (constant, linear, square, cube, etc.) are said to run in a reasonable amount of time.\ 
- Algorithms with
exponential or factorial efficiencies are examples of algorithms that run in an unreasonable amount of time.\ 
- A problem is a general description of a task that can (or cannot) be solved algorithmically.
An instance of a problem also includes specific input.
- For example, sorting is a problem; sorting the list (2,3,1,7) is an instance of the problem.
- A
decision problem is a problem with a yes/no answer (e.g., is there a path from A to B?).
- An
optimization(优化) problem is a problem with the goal of finding the “best” solution among many (e.g., what is the shortest path from A to B?).
(2) Heuristic
Some problems cannot be solved in a reasonable amount of time because there is no efficient algorithm for solving them. In these cases, approximate solutions are sought.
- A
heuristic is an approach to a problem that produces a solution that is not guaranteed to be optimal but may be used when techniques that are guaranteed to always find an optimal solution are impractical. (Example: find an optimal route)(最优解不现实,寻找近似解).
- Example: find the best route from a to i

3. Exercises