The essence of "the path of algorithms" is hard to solve.
Difficult to solve the problem section in algorithm path
- This book is written by Yan hengming, the author has another book, "The string of data structures", and "the philosophical principles of operating systems ".
- This book can be regarded as a simple example. The article is very good, and the author adds a lot of his own ideas.
- This article includes the hard-to-solve part.
Chapter 2 ease of solution and difficulty
- The easy solution refers to the polynomial problem, and the hard solution refers to the exponential problem.
- Decision Problems
- Yes/No
- If the answer is yes, a witness is usually required to prove it. A potential witness is proved to be a real witness.
- Mutual conversion between optimization and decision-making problems
- P Problems
- Deterministic polynomial time Solution
- For a decision-making problem, the input size is n, which can be solved within the polynomial time of n. Correct output is/No
- NP problems
- Non-deterministic polynomial time Solution
- For a decision-making problem, the potential witness with the size of n can be resolved within the polynomial time of n, and whether the witness is true
- The P-type question refers to the ability to give answers to polynomial time, And the NP-type question refers to the ability to determine whether a potential answer is correct within polynomial time.
- (Deterministic) Turing Machine
- The Turing machine is a state machine that determines the output, head movement direction, and next state based on the current state and next input character.
- Any problem or algorithm can be expressed as a string. Therefore, the Turing machine can solve many problems.
- Uncertain Turing Machine
- Compared with the deterministic Turing machine, a given State and input can have multiple options
- Able to enter all status paths at the same time, and make the best choice to reach the acceptance status
- Non-deterministic algorithms: algorithms run on non-deterministic Turing Machines
- Another definition of the NP problem: using non-deterministic algorithms to solve the problem in polynomial time
- Relationship between P and NP
- All P-type problems are NP
- All NP is not necessarily P, intuition is so, but it cannot be proved
- Some NP is P, and polynomial solutions have been found. Currently, NP problems with polynomial solutions are called NP-hard.
Chapter 2 NP complete Problems
- If every problem in NP can be reduced to S by polynomial time, S is called NP hard (strictly defined ). S is no easier than any problem in NP
- If the problem S is both an NP-hard and an NP-internal problem, it is called an NP-complete problem.
- NP full attributes
- Non-deterministic algorithm polynomial time Solution
- Complete: solves all NP-complete problems.
- If we find a deterministic solution to the NP complete problem, we prove that NP = P
- If a polynomial time solution for NP-hard optimization is found, NP = P is proved.
- NP completeness: if a problem can be proved to be an NP-complete problem, no more precise solutions are needed to find an enlightening approximate solution.
- Common NP problems
- 3-SAT
- Integer Segmentation
- Vertex Overwrite
- Hamilton circuit can be reduced to the traveling salesman problem
- Full subgraph
- Graph Coloring
- Traveling Salesman
- Integer Programming is an NP-hard problem, but it is not an NP-hard problem. Therefore, it is not an NP-complete problem.
Chapter 1 no solution and Approximation
- NP is only the most difficult problem in NP. Currently, polynomial solutions are not found.
- Difficult to solve the problem without polynomial solution
- The problem cannot be decided: there is no solution, and even the index level does not help. But potential witnesses
- For NP-complete and hard-to-solve problems, we can try to find sub-optimal solutions.
- Smart effort
- Optimal Solution
- Two pruning strategies: backtracking and branch Restriction
- For example, eight queens
- Approximation Algorithm
- Approximate solution can be found
- Such as clustering problems, heuristic search, simulated annealing, Genetic Algorithms
- Local Search
- A greedy strategy
- Moving continuously to a better feasible solution may only find the local optimal solution
Reprinted by: Focustc. The blog address is http://blog.csdn.net/caozhk. The original link is opened by clicking
How about algorithms?
As a student interested in programming and not a computer Major, I have always wanted to have a systematic learning of algorithm theory. I bought an introduction to algorithms, but I found it difficult to read it. I was often frustrated by the mathematical reasoning in my book. Therefore, this book has been read intermittently and has not yet been completed. I accidentally saw this book "The path of algorithms". It was interesting to read at the first day. At the beginning of each chapter, the author introduced the topic to be discussed in this chapter through an interesting story. In the topic discussion, some examples of life are often used to explain and supplement each angle. There are many text descriptions in the book, but less mathematical derivation. It can be seen that the author tries his best to make the language lively, reduce the boring and abstract mathematical formula reasoning, reduce the difficulty of the reader's learning, and stimulate the reader's interest in reading. As stated in the book, "The goal of this book is the logic behind algorithms. It is a book of inspiration, not an all-encompassing algorithm ". This book introduces the basic knowledge, design analysis, and classical algorithms of algorithms, as well as hard-to-solve and non-solution problems. It discusses the main aspects of algorithms and gives up the completeness of the introduction. Therefore, this book is suitable for beginners to read. At the same time, the book also has some shortcomings that need to be improved. Although the author tries to minimize mathematical descriptions, mathematical descriptions are inevitable to clarify certain algorithm problems. However, some of the mathematical descriptions in the book are rough, and the meaning declaration of related variables is unclear, which makes it more difficult for beginners to understand. In short, compared to the "dinner" of algorithm learning such as "Introduction to algorithms", you can refer to "The Road to algorithms" as a "appetizer" before meals ", let beginners have a preliminary understanding of algorithms: the original boring algorithms also have their own interesting stories.
A difficult mathematical problem
It would be easy to resolve this question. Use ac and bc as the coordinate axes and set points.
If you do not need the parsing method, use the common method.
Add the Triangle ABC to the Growth square ABCG, that is, the rectangle with AB as the diagonal line, extending FD compared with AG in H, connecting EF, EH,
It can be proved that AH = BF and DH = DF (you can use a full equal), then AE ^ 2 + BF ^ 2 = AE ^ 2 + AH ^ 2 = EH ^ 2,
CE ^ 2 + CF ^ 2 = EF ^ 2,
Therefore, EH = EF, that is, the triangle EHF is the isosceles triangle, and D is the middle point of HF, so the ED vertical HF, that is, the request.
Score.