What is algorithm? If you want to enter this world, you shouldn't know, this beautiful world, what happened? What is algorithm? Yes, this is a problem. Its significance is comparable to that "to be, or not to be", if we are like Hamlet:) ...
We may wish to review the last question, SAT problem. Of course, considering the problem should always start from the simplest place. See the simple example below, 10 logical variables:
C0: -X0 V-x3 V x5
C1: -X1 V-x6 V x7
C2: -x5 v x8 v x9
Is this a collection of clauses? Oh, we have to solve it, we have a way, or if this, 10 logical variables, we give a set of assignments:
True, True, True, True, True, True, True, TRUE
To test C0, C1, and C2, if the clause is true, this group assignments meet the requirements, returns it, and end. Otherwise, we will try one:
True, True, True, True, True, True, True, False
......
If all the assignments have not been searched, all clauses of this collection are really assigned, then the output is not satisfied.
This is our idea. Of course, we can write a "character text that describes the precise step", which indicates a way to solve the problem step by step. We summarize it, this is the definition of the algorithm, the method of solving the problem step by step, it has the following characteristics:
(1) It must be a limited text representation;
(2) Every step must be mechanically completed in a limited time.
This description is well understood, but as the basic concept, the algorithm has a formal definition? We know that if there is a poor self-motivation, its algorithm has a formal definition, and the general meaning algorithm has not been seen. I also want to be defined, but I don't know what it is.
But for the algorithm, there is still a discussion. Let me first ask you:
Can the algorithm can be executed?
"Haha, I wrote a 'algorithm', the computer does not end ..." Is this a algorithm? " is it? Not? Oh, how do you think, let me talk about it. My opinion, of course; algorithm can of course be infinitely executed. (Here we say that the evolution of the Co-calculation has an example: you write a clock algorithm, it will never stop ... isn't it also an algorithm?)
So, I will ask the second question:
What makes some problems difficult to solve, and other problems are easy to solve?
For example, the last example, seeing NAT and, for example, n = 1000, such as n = 1000, this problem computer can be calculated in an instant, and the SAT problem of 1000 variables, the computer is only a bit difficult to calculate. why? What is the fact that the decisive role makes our algorithms so different? Can we fully understand its essence? There is no doubt that there is no current research results in decades, we have a standard that divides the problem into several categories. We know what is a problem. I only know it is a problem. The problem is far more than this. But we will not fear unknown!
In fact, it is because these difficulties exists, because there is an unlimited wasteland, there is a Gobi, there is a beach. Our world has a unique charm ... I believe that countless people hope to open a green wilderness here. I hope to work, adventure, taste, have fun, or fail!
Oh, are you ready? Is there a full confidence, follow me? If so, I will tell you this world in my eyes, her unique, beautiful, swaying ...
This world, with her brothers and sisters have thousands of relationships.
First, the world of the algorithm will have a great difference due to the different mathematical models. Let's see this example, don't say it simple :):
E.G.1 Squake the root: AX B = 0 (a! = 0) Ask yourself, how would you solve it? Using a computer, I think you will think so: there is X1, so that A * x1 b <0, exists X2, make A * x2 b> 0, then, use a 50% off the semi-method iteration search within the interval [x1, x2] ! If you solve this, I am not strange. In fact, my first reaction is also a solution. The mathematical background of this algorithm is the numerical method within the error control. Of course, very excellent algorithms. Also suitable for this question.
However, if you leave it to any primary school student who has learned a simple equation, I think he (she) solution is no doubt: AX B = 0 ax = -b x = -b / a (a ! = 0) Oh, how? You may say, "Oh ... Yes, if you have a calculation (in other words, people count :), I have been solved like this. However, with a computer ...". Can you use your computer? You noticed that people solve problems are logical thinking, not searching or iteration by step. If the mathematical model we consider at the beginning is another look, our algorithm will be completely different:
Definition: Individual Domain: Real Equivalence R Function: Add (A, B): A B MUL (A, B): A * B
Presequence: Equal (a, b): a == B Rules: Any X, Y IN R, Equal (Add (x, y), 0) -> Equal (x, add (0, -y)) Any X, Y, Z IN R, Equal (Mul (x, y), z) -> Equal (x, mul (z, 1 / y)) rule set is the most important Two, the other did not add it; but it can be discussed. Based on this logic system, we can use similar algorithms similar to the machine to fully introduce the solution.
what do you think? Perhaps, you don't care about the mathematical model for equations, but do a large expert system, you must take care of this problem.
Post: This problem I always makes you define a function f, parameter is A, B, return -b / a :). Oh, maybe an example is too simple. But I need you to focus on the process of "calculation".
Second, the world of algorithms is different due to the difference in computer architecture.
We still consider a simple problem last time, ask :). Now is:
E.G.2 has n data, summation
How do you solve it? Oh, is I asked very stupid? Or, do you blame me too stupid? Haha, no, if you ask the majority programmers (including the quasi-course of the students), more people will say:
A loop: sum = 0; for i = 0 to n-1 do sum = a [i]; where A [] stores data. If he is a careful person, he will consider that SUM will not overflow so that he may consider a data structure to store results.
There is no problem algorithm to some extent satisfies the requirements of the topic. However, your algorithm is based on a single processor! This work, if you have a network cluster in your company, you may not use this serial algorithm, you need a parallel algorithm. Then, you need to split the problem and consider the overhead of communications. The algorithm will completely change!
Finally, a lightweight feature, the world's world is different due to the size of the problem. At the beginning, the SAT problem analysis was a good example. We may be exhausted 10 logical variables, but exhaustive is definitely not the available algorithms for this issue! Otherwise, its time overhead will grow according to the exponential level!
And I have a project, the evolution calculation is solved, and I will also analyze this problem later. Including climbing method, A algorithm, A * algorithm, and of course there are final solutions, evolution calculations.
All in all, the algorithm world can be described more. Because I love her love, I voluntarily to do the guide, although this guide is not good, but still hopes that you should not refuse the beauty of the scenery!
The source of mathematics and algorithms will be discussed next time.
The topic of this post: