Algorithm a familiar and unfamiliar word. I used to be very agitated when, want to go to each job candidate or interview, then people ask algorithm you will? When I heard it, I was blinded, only shaking my head.
God, as the undergraduate computer professional study of college students, actually do not know what is the algorithm. I'm so blushing.
So what is an algorithm?
After touching some people, some things, some education, plus often think about what is after. Finally decided to send such an essay, to share my views on the algorithm this thing.
It is not convenient to check the definition of the algorithm. The net is broken ... According to my impression, the algorithm is the process of dealing with a problem. It can not be like a program, there is the necessary input and output, what finite times, correctness. He is simply a point of view on a problem. For example, take the file stream operation, open the file, write the content, close the file. This is the algorithm.
Swaps the position of two data in the array. This is something that can involve data structures, such as at least knowing what an array is. You know how to define data in memory. It's possible to think of introducing a unit again. As a transit point. So algorithms are often associated with data structures.
When it comes to connections, what are the factors that are related to the algorithm, in addition to the data structure? Since it is said (what I call) its definition, it is the logic to solve the problem, thinking. Then it is bound to be related to the problem itself, the previous example, that is, the exchange of data location, then if it is a number, you can less introduce a unit to reduce the cost of memory (this way everyone has seen, do not write). It has to do with the people who deal with the problem. And what does that man have to do with anything? With people's views of the problem, as well as human experience, experience. People on the question how to see, the first two days with the students to discuss the problem of the deletion of the node: a pointing to B, B pointing to the C, C pointing to the ding, now requires in O (1) time to delete the second node of the unidirectional list. What do you do? Of course there are many elements in front of a, and there are many elements behind the ding. Just to have a good description of the problem later. In order not to let the chain broken off, how to have to go through, get a, and then put the chain C to a back, and finally the second deleted. Thought for a long time, also can not solve, and finally was shared the answer: because B to be deleted, so actually do not care about the existence of B, may wish to assign the value of C to B, B point to Ding, and then the C deleted. The way you look at the problem is different, the way it is resolved. Experienced more, naturally there is a solution, the number of processing times more experience will have. Just like this list, I do not say, you have not heard, it is difficult to think how to do; I said, you write down, you will almost forget.
So I'm actually quite disgusted with the algorithm at the time of the interview. Even more frightening is the algorithm tuning problem. Because sometimes this kind of thing is like a brain teaser. The logical, or algorithm, of a reasonably good handling problem, if described by an equation, should be a full understanding of the problem, coupled with the right inspiration, plus proper rest and relaxation. Can not understand the problem, how can not think of such a deceitful rescue (delete C, not the equivalent of B) method. Just the right inspiration, sometimes, you can do it yourself, sometimes, you may need to go out, play, sad a while, lost, like the rabbit in the Crazy Zoo, always with carnivorous animal hay food animal that problem knock, may not have progress, but if go home rest few moments. Maybe you can get a clue about the problem. See the flowers that make animals mad. Of course, the source of inspiration is not on their own, you need to communicate more with others, still need an optimistic attitude. So I hit the algorithm problem, my mood is the day the dog. This time, do not want to optimize, first solve the problem, and then take the language to write, first let him run correctly, the back of the matter, and then again. Don't do it because you're afraid, or if it's a disgusting algorithm. Although I do still think the algorithm is to some extent equivalent to the brain teasers. Some what "咵 cha" hit the floor to ask you how not bad TV, "lamp" dropped a ask you tires there are a few, you have to see know this sharp turn, you can not, you have not seen, is not done, so the algorithm is actually to examine the problem is you see the number of problems, and you face the problem attitude. Think so, it might be better.
The implementation algorithm is related to the language, which is related to the familiarity of the language. Just say it first and then take the right language to achieve it. Some of the problems are beyond, and some are very efficient. Different languages can have different effects. For a healthy child of ten years old and a wise young man and an experienced elder, if they all speak Chinese, then the description of the same problem must be different. Writing procedures is like talking, the child may be able to talk about the problem clearly, the youth, may be more in the language, the elderly in addition to the well-informed, the grasp of the language is also profound, concise, a few figures will be clear. This is really very important to the language itself, and to the mastery of language.
The algorithm tuning is related to the person's experience and understanding of the problem.
See some recruitment requirements, the request can be tuned to the algorithm, really casually pull a lang, then want to get married and have children, grandchildren full house. Think too much. I think how to tune an algorithm. This needs to be a matter of thumb. How to be understood thoroughly, can be in front of the director and general manager of this logic clear (don't say what programmer will not communicate with people, do not understand the problem, will only knock code. I think as long as it is the matter can be able to speak clearly, especially on the procedural, logical this together, if not understand can only be his own do not understand. ), to be able to create this algorithm in front of the person, while talking and knocking. If I had to add a scalar to these things, I'd say, at least 5 times at the bottom of the dictation .
Still in the ivory tower inside, casually said a lot, I think will not algorithm tuning, and you ask you will not cook, can play table tennis, will drive the same, will not swim the same. He doesn't really actually correspond to you will still not have two endpoints. He's a serial thing that can't be described with a function. But I know there are several parameters in it. For example, if it is cooking, with your mood, state, the mood is not good to knock out the code comments are not very words. If you are driving, although you take a driver's license, only you know you back to the side of the library and the end of the stop, although you have been certified, but only you know your depth. If it's a swim, only you know how far your limit can be, and how wide you can tune it. If you are playing ping-pong, your wife will look at the action, I know if you can play, if you could at least get a small competition champion, at least you can cultivate. At least not to be taken from scratch. (The following things are irrelevant-if the computer can pull all these things by itself and use a function to describe, or give the computer a chaotic era, for him to break the breakpoint, if the real-time monitoring he can evolve into the slave society, or feudal society, it can basically let the system stop, But I think that time is basically late, because computer systems have learned to learn, to learn to create rules, I think the computer can learn the rules, and create their own rules of the moment, is the computer to rule the moment. Welcome to see my other view on the victory of Alphago and how intelligent AI can govern the world. )
All on the road, with everyone to encourage.
The algorithm in my eyes