官术网_书友最值得收藏!

Algorithm design paradigms

In general, we can discern three broad approaches to algorithm design. They are:

  • Divide and conquer
  • Greedy algorithms
  • Dynamic programming

As the name suggests, the divide and conquer paradigm involves breaking a problem into smaller sub problems, and then in some way combining the results to obtain a global solution. This is a very common and natural problem solving technique, and is, arguably, the most commonly used approach to algorithm design.

Greedy algorithms often involve optimization and combinatorial problems; the classic example is applying it to the traveling salesperson problem, where a greedy approach always chooses the closest destination first. This shortest path strategy involves finding the best solution to a local problem in the hope that this will lead to a global solution.

The dynamic programming approach is useful when our sub problems overlap. This is different from divide and conquer. Rather than break our problem into independent sub problems, with dynamic programming, intermediate results are cached and can be used in subsequent operations. Like divide and conquer it uses recursion; however, dynamic programming allows us to compare results at different stages. This can have a performance advantage over divide and conquer for some problems because it is often quicker to retrieve a previously calculated result from memory rather than having to recalculate it.

主站蜘蛛池模板: 南宫市| 沙洋县| 马关县| 漳州市| 邹城市| 淳化县| 墨竹工卡县| 五河县| 宝清县| 鹿泉市| 和林格尔县| 怀远县| 文山县| 弋阳县| 泰兴市| 东乌珠穆沁旗| 扶余县| 西林县| 上饶县| 布尔津县| 易门县| 怀安县| 横山县| 黄冈市| 桑日县| 泗阳县| 嘉祥县| 凤庆县| 涞源县| 赣州市| 雅江县| 腾冲县| 延边| 杨浦区| 眉山市| 芒康县| 馆陶县| 乌苏市| 明星| 通河县| 阿鲁科尔沁旗|