Program algorithm and Life choice

Source: Internet
Author: User
Tags filter return sort

Every year when it comes to looking for a job, I can receive a lot of people sent me the mail, always ask me how to choose their offer, to Tencent or to the watercress, to foreign companies or to the domestic enterprises, to venture or to graduate, to Beijing or home, should not go to innovation factory? Should I go to thoughtworks? ...... Wait, wait. This year from July to now, I received and responded to more than 60 such emails. I help them organize their ideas more and help them understand what they want most. (Note: I will not reply to a similar message later).

I deeply found that for our country so from childhood parents and teachers to arrange a variety of things to grow up, when one day, parents and teachers are not up to, we almost completely do not know how to choose. And I've recently left the Amazon and changed my job. And at the end of the year, like the three stories and three questions of the last one, it made me think of writing an article like this.

Several examples

When we are faced with a variety of factors affecting the choice, such as: City, company size, company nature, salary, project, hukou, technology, direction, vision ... You will always find that you will find yourself in two companies, for example:

· A netizen and I said, they go to Shanghai Tencent, because the size of Tencent is very large, but found that salary generation without high (low is not a point), if you want to change jobs, starting pay point directly related to the future of high wages. I said that go to watercress, he said watercress in Beijing, pollution is so serious, and there is no account, the living environment is not good. I said to Tencent, he said Tencent recently organized adjustment, instability. I said that go to watercress, slow company, the development is very steady. He said that watercress's profit is not clear, and use Python, they do not like. I said, then go to Tencent, ...

· There is a netizen and I said, he wants to go back home, because the relationship between the hometown is better, can mix well. But want to stay in the big city, because the big city can open the eyes.

· Another netizen and I said, he wants to enter the foreign enterprise, practice English, open an eye, but also fear in the foreign enterprise when a screw, the idea is not implemented. Friends pull him to start a business, think entrepreneurship is good, exercise big, but friends do that do not know can do.

· There is a netizen in the innovation workshop of a team and grind between the choice, do not know to innovate factory line, think that the general, but feel that the team is very passionate, on the other hand feel that their education is not enough, read a research should be able to find a better job.

· and a few friends. What skills should I learn? What techniques should not be learned? Or how to learn the fastest, the path of technology should be what? Some say only do the back end does not do the front-end, and some say, only do algorithmic research, do not do engineering, etc., and so on. Because they feel the life is limited, the surgery profession has specialized.

· Wait, wait......

I personally think, if it is not a computer-born people will not make a choice, do not know how to go, but we are born of computer science is learning algorithms, people who know the algorithm should know how to make the choice.

Sorting Algorithm

You can't have everything, so you just want what's important to you, you know what's important, you need to have a clear understanding of those desires and ambitions in your heart, or you'll spend it in a tangle.

Therefore, in the selection of the tangle of people need to refer to the sorting algorithm.

· First, the most important thing you need to refer to is " bubble sort "-the idea of this algorithm is to bubble up a maximum number each time. So, you need to ask yourself, in the face of those factors that affect your choice, if you can only have one, which one would you like? And the rest can give up. So, when you put the maximum number, one bubble out, and use this decision factor to filter the options, you can easily know what you should choose. The algorithm tells us that the less people have the distraction, the easier it is to make a choice.

· Well, maybe you're at a loss. How to compare the size of two decision factors, such as: You can not understand, salary > business prospects? Business Outlook > Capability improvement? So you have absolutely no way to bubble. Then you, you might want to refer to a " quick sort " idea--the algorithm tells us that we don't need to find the biggest number in the first place, we just have to take out a certain standard in your values, and then put the value to the right, not the left. For example, your standard is: More than 5000 yuan && business prospects longer than 3 years of companies, you can use this standard to filter your options. Then, you can adjust this standard and then go on with the recursion. The algorithm tells us that the clearer our selection criteria, the easier it is for us to make choices.

This is the ranking algorithm of the most classic two algorithms, interview must test. I believe you know in the heart. So, I think it's not a problem for you to apply this algorithm to your life choices. About, do you know what you want?

The central idea of the sorting algorithm is to help you identify what you need most, to recognize what you want most, and then to choose from that.

Greedy Algorithm

A greedy algorithm is a choice in which each step chooses to take the best or best (i.e. the most advantageous) option in the current state (note: The current state), thereby hoping that the result is the best or optimal algorithm. One of the most classic examples of greedy algorithms is Huffman coding .

For humans, the average person uses the greedy algorithm when acting.

· For example, in the search for change, if you want to make 36 yuan, we will generally be in the order of the changes: 20 Yuan, 10 yuan, 5 yuan, 1 yuan.

· Or when we cross the intersection, from the block to the diagonal, we also use the greedy algorithm--which is the green light first, we'll go over there first, then turn around 90 degrees and wait for the red light to cross the street.

There are many examples of this. For the choice, most people will choose greedy algorithm, because this is a relatively simple algorithm, the future is too complex, can only take a step to see a step, in the current situation to make the most conducive to their own judgments and choices can be.

Some people will be greedy salary, some people will be greedy to do the project, some people will be greedy business, some people will be greedy position, some people will greedy their interest ... There's nothing wrong with that. Greedy algorithm is not wrong, although not the global optimal solution, but it can let you find the local optimal solution or suboptimal solution. In fact, a suboptimal solution is also good. Greedy algorithm is basically a quick success of the algorithm, but does not mean that this algorithm is not good, if the greedy is a long-term and sustainable, but also not to do?

Dynamic Programming

But we know that for most problems, greedy methods usually do not find the optimal solution, because they generally do not test all possible solutions. Because greedy algorithm is a short-sighted behavior, only with the current form of judgment, that is, premature decision, and therefore can not achieve the best solution.

The biggest difference between dynamic programming and greedy algorithms is that the greedy algorithm makes a choice and cannot be rolled back. Dynamic planning saves the previous result of the operation and chooses the current selection based on the previous results, and has a fallback function.

The dynamic programming algorithm tells us at least two things:

1 It is very important to follow the past, when you are ready to do the traversal, your last experience will not only open your future experience, but also for the later experience to use. You are not wasting every step of the way.

2 It is also important to have a fallback. This means--if you have two options in front of you, one is a company B, if you miss Company B today, will you be able to find it tomorrow?

For example: You have two offers, one is Yahoo, one is Baidu, the above 1th will let us think, Yahoo and Baidu who can give us to open a bigger platform? The 2nd above tells us, is to enter the Yahoo if did not choose good, whether still can return to Baidu company? Or after entering the Baidu company can easily return to Yahoo company?

Dijkstra Shortest Path

The shortest path is a greedy + DP algorithm . Quite classic. The effect of this algorithm is as follows:

1 when initializing, all the nodes and I are infinite, default is not reached.

2 from the closest to their own knot began to greed.

3 go over and see what kind of nodes you can reach, and calculate and update the distance to all the target points.

4 greed and the origin of the shortest node, so repeated.

This algorithm brings us to some of these revelations:

I remember a friend who told me that he wanted to be an architect, or an expert in a technical field, and that he would step forward and never give up. I encouraged him, but I also told him the famous algorithm, I said, this algorithm tells you that architects or experts in the field of the current distance is infinite, they put in mind, first look at what you can get. The so-called steadfast, is not a steady pursuit of your goal, but do you have enough to see on the side of things to do well. I remember when I first took part in the job, when I came out from my hometown, I never wanted to be a technical cow. Also never thought of my blog will be so influential, in doing their own ability to see the touch of things, I saw what technology to learn what, learn to learn how to learn more relaxed, how to learn more solid, This may be my shortest path.

A lot of friends asked me whether I want to learn C + +, or ask me to learn Python or Ruby, is not to learn the front end, and so on. These friends tell me that they can not learn multiple languages, learn not to forget, and the operation of the industry has specialized. This is nothing wrong, but I personally think that learning a thing is not necessary only two states, one is not learning, the other is proficient. To understand a technology actually does not take much time, I learned the purpose of C + + is actually to better understand Java, learning TCP/IP protocol is in fact, in order to better understand the socket programming, many things are connected and complementary, learn the C/C++/UNIX/TCP and other basic technologies, I found that getting to the other technical path was shortened (which is why I can understand the go language for two days). This is like this algorithm, the algorithm is not very efficient, perhaps to achieve your goal, you spent a long time in the beginning, traversing a lot of places, but, this may be your shortest path.

The algorithm is trade-off .

There's no way you can get everything you want, and any choice means giving up--when you're going to get something, you always have to give up something. Life is a seesaw, one on the other, the other is bound. This is like the way we do software design or algorithmic design, use time to change space, use space to change time, and cap theory, there are always a lot of trade-off, just like the original phrase--you always have to trade something with something.

We're all using something to trade our future, some people use their own efforts, some people with their own thinking, some people with their own youth, some people with their own freedom, some people with their own values, some people with their own morals ... Some people are exchanging money, some people in the exchange of vision, some people in the exchange of experience, some people in the exchange of status, some people in the exchange of power, some people in exchange for freedom, some people in exchange for interest, some people in exchange for vanity, in exchange for ease and pleasure.

Everyone has an algorithm, each algorithm has the purpose of each algorithm, even if you are using the same algorithm, but everyone in the algorithm of those variables, switches and conditions are not the same, the results are not the same. We are living in the matrix of a program, each of US's algorithm determines the choice of each of us, our choice determines our life.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.