当前位置:网站首页>Part I - Chapter 1 Overview
Part I - Chapter 1 Overview
2020-11-08 17:48:00 【Li Lihao】
Data structure introduction
Three reasons to use data structures : efficiency 、 abstract 、 reusability
Introduction to the algorithm : efficiency 、 abstract 、 reusability
General method of algorithm design : Random method 、 Divide and conquer method 、 Dynamic programming 、 The law of greed 、 Approximate method
General method of algorithm design
Random method
Random methods rely on the statistical properties of random numbers . For example, an example of applying the stochastic method is Quick sort .
Divide and conquer method
Divide and conquer contains 3 A step : decompose 、 solve 、 Merge . An example of divide and conquer is Merge sort
Dynamic programming
Dynamic programming is similar to divide and conquer , All of them decompose the larger problem into subproblems, and finally merge the results .
The difference , In dynamic planning , The way the problem is handled is related to the relationship between the subproblems . In divide and conquer , Each subproblem is independent .
therefore , In divide and conquer, you can use recursion ( The first 3 Chapter ) The way to solve each sub problem , Then merge the results with the results of other subproblems .
The law of greed
The greedy method can always make the best choice at present when solving problems . let me put it another way , It's not about the overall optimum , And it's just a local optimal solution in a sense .
An example of a greedy approach is Huffman coding ( The first 14 Chapter ), It's a data compression algorithm .
The most important part of Huffman coding is to build a Huffman tree ( Also known as the optimal binary tree ).
- (1) To build a Hoffman tree , From its leaf nodes, from the bottom up . Take each compressed symbol and the number of times they appear in the data ( frequency ) Save together as the root node of the binary tree .
- (2) Next , Select two root nodes with the minimum frequency as the left and right subtree nodes , Construct a new binary tree , And the frequency value of the new binary tree root node is the sum of the frequency values of the left and right subtree nodes .
- (3) Then repeat this step , Know to get the only tree , This is the final Hoffman tree .
The root node of the Huffman tree contains the total number of symbols in the data , Leaf nodes contain the original symbols and how often they appear .
Huffman coding is a greedy algorithm , Because every time it selects the most suitable two trees to merge .
Approximate method
The approximate method does not calculate the optimal solution , contrary , It only calculates “ Good enough. ” Solution . The approximate method is usually used to solve the problems that are expensive to calculate and unwilling to give up because of its value .
Salesman problem ( The first 16 Chapter ) It's a problem that is usually solved by approximation .
版权声明
本文为[Li Lihao]所创,转载请带上原文链接,感谢
边栏推荐
- 一分钟全面看懂forsage智能合约全球共享以太坊矩阵计划
- Solution to cross domain problem of front end separation
- Gopherchina 2020 Conference
- Flink的sink实战之一:初探
- 函数分类大pk!sigmoid和softmax,到底分别怎么用?
- I used Python to find out all the people who deleted my wechat and deleted them automatically
- One minute comprehensive understanding of forsage smart contract global shared Ethereum matrix plan
- 学习记录并且简单分析
- Summary of rendering of water wave and caustics (etching) in webgl
- WordPress网站程序和数据库定时备份到七牛云图文教程
猜你喜欢
趣文分享:C 语言和 C++、C# 的区别在什么地方?
构建者模式(Builder pattern)
Chapter 2 programming exercises
进入互联网得知道的必备法律法规有哪些?
Learn volatile, you change your mind, I see
Use markdown
Opencv solves the problem of ippicv download failure_ 2019_ lnx_ intel64_ general_ 20180723.tgz offline Download
Flink series (0) -- Preparation (basic stream processing)
[elastic search technology sharing] - ten pictures to show you the principle of ES! Understand why to say: ES is quasi real time!
[elastic search technology sharing] - ten pictures to show you the principle of ES! Understand why to say: ES is quasi real time!
随机推荐
Travel notes of Suzhou
AI perfume is coming. Will you buy it?
C/C++知识分享: 函数指针与指针函数,看完这篇你还能不懂?
Solution of DEV-C + + unable to debug in Windows Environment
PHP generates unique strings
latex入门
京东落地DevOps平台时爆发的冲突如何解决?
read文件一个字节实际会发生多大的磁盘IO?
苏州游记
框架-SPI四种模式+通用设备驱动实现-源码
C / C + + knowledge sharing: function pointer and pointer function, can you understand after reading this article?
SQL quick query
experiment
如果把编程语言当武功绝学!C++是九阴真经,那程序员呢?
关于adb连接手机offline的问题解决
Elasticsearch 学习一(基础入门).
Recurrence of Apache kylin Remote Code Execution Vulnerability (cve-2020-1956)
[random talk] JS related thread model sorting
Dynamic ReLU:微软推出提点神器,可能是最好的ReLU改进 | ECCV 2020
(O) Analysis of service manager (1) BinderInternal.getContextObject