A Google Programmer's algorithm learning path

Source: Internet
Author: User
Tags explode

Source: Lucida (@peng_gong) about

Strictly speaking, this topic should be my data structure and algorithm learning path, but this writing is too much to the mouth-and CS in the algorithm often dark index according to the structure and algorithm (for example, the introduction of the algorithm refers to the data structure and algorithm introduction), so I think the title of this article is reasonable.

What does this article say?
    • I've been learning about data structures and algorithms over the years.
    • Some nice algorithms for books and tutorials.
    • The importance of the algorithm.

The first contact data structure is in the sophomore semester of the data structure course. But the course didn't get me started-I was so busy reselling all kinds of MP3 and headphones that I was totally dismissive of these courses--anyway, the final exam was a big one, so the most important course for the whole computer major was stupid. I just ignored the past.

Until the junior I reacted to the later still need to find a job-and the sophomore toss proved that I do not have any business talent, and later still have to rely on code code bread where eat, I was frightened to find that the program is almost ignorant, so I have developed a similar to the beginning of the founding five of the book Growth Plan, These include the C language Foundation, the data structure as well as the computer network and so on books.

The first step of the book plan is to choose books, I have to the time I feel very cattle "seniors" and "great God" to consult what algorithm books, "seniors" are recommended "Introduction to the algorithm", there are several "great God" Recommended computer programming art (now I suspect they have turned over these books), A cursory turn over these two books found really do not understand, but fortunately I accidentally found the bean paste this magical website, there are many good quality reviews, so I put the evaluation of high and seemingly less scary computer books have been bought down-the fact that the watercress than these "seniors" or "great God" is reliable A lot more.

Data structure and algorithm analysis--c language description

Data structure and algorithm analysis--c language description is my first book to learn the data structure: There are many places do not understand, so make the mark repeatedly read, the code can not understand, and then copied to the book repeated study; some algorithms do not make sense, it all the middle state and then repeatedly deduce. It turns out that although this kind of learning method looks silly and inefficient, but for the same silly at that time I did a good job-silly people with silly ways, and this book is mostly a classic interview topic, so that in the future I see the beauty of programming the first reaction is that the title of the goods is not all copied others.

Still remember, this book to illustrate how important the algorithm is, in the beginning to take the largest subsequence and as an example, the complexity from O (N3) to O (N2) to O (NLGN) finally to O (N), then the heart is really admire the feeling = such as the surging river, why can such a dick,

In addition, I was also the book in the figure algorithm before the data structure of the whole hand, and later to find an internship is quite complacent to put this matter in the resume, now think of really stupid no limit.

By virtue of the knowledge learned from this book growth program, I finally found an internship, which is something.


My internship did not use any algorithm (now seems to be piling up the existing API, write a bunch of their own do not know the right code only), in the discovery of people around the work for several years but still and I do the same thing, I began to become more and more uneasy. Although I had no plans for myself at the time, I knew that the cliff was not the job I wanted to do.

The Dream factory of Microsoft

In this wavering moment, Microsoft's dream Factory became the last straw to overwhelm the camel, this book on Microsoft Research Asia let me make up the "find a job to this company" determination, but I also pessimistic found that whether I was at the time of the ability or diploma, can not meet the requirements of Microsoft Institute, contradictions, I completely overturned my "graduation on the job" idea, quit the internship, ready to grind.

The details do not need to repeat the examination, but still clearly remember that they were surprised and excited in the second-round examination of the northern dormitory is the Microsoft Sigma Building, the kind of a step away from the idea of the feeling is really cool to explode.

Algorithm Design and analysis

My graduate career is definitely a negative example-skipping classes, internships, writing water papers, doing water research, but one thing I'm quite complacent about--listening carefully to Professor Han Jun's algorithm design and analysis course from beginning to end.

Han Jun gave me the deepest impression of two points: the class break to run outside and a few students asks smoke, explain the algorithm is sharp and unambiguous.

Although Han Jun never mentioned it, I'm sure the algorithm design and analysis base is the de facto (de-facto) textbook of his algorithmic course, because his curriculum structure is almost identical to the structure of the book.

If the data structure and algorithm analysis--c language description is my data structure enlightenment, then the Korean Army's Curriculum and algorithm design and analysis is based on my algorithm enlightenment, combined with courses and books, I one by one understand and master the complexity of analysis, division, reduction, governance, dynamic planning and backtracking these simple but powerful algorithm tools.

Introduction to Algorithms

Introduction to the algorithm is I inadvertently read another algorithm book, and the ordinary algorithm book, the book from a creative point of view-if the introduction of the algorithm is what the algorithm, then the introduction of the algorithm is how to create the algorithm. Combined with the previous algorithm design and Analysis Foundation, this book expands the number of algorithmic problems I can solve by an order of magnitude.

Then, in the chance coincidence, I entered the Microsoft Asian Engineering Institute Internship, a step closer to the ideal, self-feeling unlimited.


The internship at the Microsoft Engineering Institute is a very, very important turning point in my postgraduate stage:

    1. Made a small project that also said the past.
    2. During the period of Baidu internship interview frustrated, the experience of reading a lot of programming books.
    3. Microsoft's internship experience has become one of the few highlights of my resume (this cock one no results, two no papers, three no ACM).

Here is not to say 1 and 3 (and this topic does not lap), the emphasis on the 2.

Since there were no special projects in the group, the small piece I was responsible for was done in advance, and mentor generously threw me a Kinect and a Windows phone. Let me study, research, naturally there is no deadline, So I was a chicken thief. Time 37 Open: Seven minutes Daoteng windows Phone, three-point book & Classic paper.

But one thing interrupted this life of ease--

Baidu Internship Interview

The basic friends in everyone Baidu internship push paste, at that time self-feeling brilliant shine, so I took a look at the domestic IT environment + abuse of the interviewer's abnormal psychology to cast a resume, the results in the first side of his brother burst Xiang: He let me write a stof (string to float), I grind haw half a day did not write the complete realization, Then returned to the dormitory quickly wrote a version sent to the Elder's mailbox, the result of the other side did not bird me.

This has been a great shock to me--

    • Originally even Baidu internship interview have to pass.
    • The original is still a programming weak force.
    • Original oneself still is an algorithm dish force.

A bitter lesson, I started the second "five", 37 open the time allocation into 73 open: seven points reading, three points WP. And the focus of this phase has changed from principle (Principle) to implementation (Implementation)--talk is cheap, show me the code.

Elements of programming

Because always feel that the name with "Elements of" are cool and fried days of the book, so I almost do not hesitate to buy this Elements of the programming, in fact, the code (or STL code) is really: fast, ruthless, quasi, Cologne master three elements of the whole QI.

C Interfaces and implementation

Baidu interview was burst of experience let me realize another problem, most companies need to write C code on paper, and I rarely use C (in most cases in C #), considering that I have not been able to let the company change the interview process, I need to improve their ability to write C code (even for the interview). After a Google, I locked the C Interfaces and implementation--another book about how to write the C code of the crazy cool handsome Diao Tian, here to apply Amazon's comments: Probably the best advanced C Book in existance.

Strictly speaking the above two books are not the traditional algorithm book, because they are not focused on the algorithm, but the implementation of the classical algorithm (implementation), but this is what I need: because of the principle of the algorithm I can say, but to give elegant and concise implementation I was stupid, Even the stof of this simple to explode "algorithm."

Still the old Fool study method: repeated reading + over and over again to copy the code to the book, after the difficult completion of the two books, and read a considerable number of programming practices (programming practice) books, self-feeling programming ability and greatly improved, in addition to acquire new skills-paper coding. It also became one of the kick for my job interview.


To tell the truth, since the undergraduate internship, I have always felt that the algorithm in addition to the interview can use, the other basic use, and even wrote a quite complacent now read extremely silly articles to black those who are still "basic" or "internal strength" of the so-called "Daniel", Here's a piece of text that looks stupid now but feels truth at the time:

So the move is what the algorithm AH basic ah, so-called Daniel, please close your mouth, all roads through Rome. The algorithm is not a prerequisite for programming, and mathematics does not prevent a person from becoming a good programmer. At least in my opinion, what algorithm basic internal strength are bluffing, multi-point can use the practical program is kingly, of course, if you are a pure theorist words when I did not say anything.

However, it is interesting to write this article not long, advocating the algorithm useless theory of my own to do a few large and small projects all use the algorithm-I suspect that God is deliberately pumping my face.

LL (k)

My first project in Microsoft Internship was code coverage analysis--Calculating code coverage for T-SQL stored procedures.

Simply looking at the SQL Server related documents, I quickly discovered that SQL Reporting service could record T-SQL execution statements and line numbers, so line coverage was done, but the boss said line coverage was too naive, We need a more realistic block coverage.

After reading the definition of block overlay, I found that I needed to parse the T-SQL and only do it myself without finding a good T-SQL parser:

Compared to strangeness, when I was doing this project I just took ANTLR author's language Implementation Patterns (Chinese) half, what LL (k) Ah Packrat Ah, the concept of AST Walker is warm.

As a result, the official EBNF of T-SQL, rinsed the LL (k) Parser of a T-SQL stored procedure, converts the code into an AST, and then uses a external AST walker to generate an HTML report that is covered by a block of code, and the whole process is less than a week.

Old nature is very satisfied-I suspect his original plan was spent two or three months to complete the project, because the project two months after I did not work, every day leisurely tour Zai.

Phonetic index

The phonetic index is a small module that I answered in a mobile app reverse telecommuting, the user expects the phone text box to give smart hints based on the input:

For example, enter China:

Similarly, you should also be prompted to enter pinyin:

Chinese match this simple, but pinyin match will have to spend time to think about--too lazy to build the wheel of my first time to find the Microsoft Pinyin Library, but then I found that Microsoft this bird bank on the mobile phone can not move, the study found WP7 on the dictionary of the items of limited system, Looks like 7000 or 8,000 item will crash, and the standard Chinese characters have more than 20,000, and a.

Scold Ms Pit Daddy + Chinese characters pit Daddy, still have to own a library out:

    1. First put the 20,000 characters out, sort, and then make a super long string.
    2. Next use Int16 index the Chinese characters all pinyin (looks like more than 500).
    3. Then use Int64 to establish the association of Chinese characters and pinyin-Chinese characters have multi-tone words, so need to put a number of Pinyin pack into a Int64, this simple, bit operation will be done.
    4. Finally, we use the two-point + displacement unpack to search directly from Chinese characters to pinyin.
    5. Later small measured performance, the speed is 50 times times more than the original library of MS, and the code amount of only 336 lines.

The user is very happy--because I took the polyphone that he did not think of, and the flow of a force.

I am also very happy, because did not expect to write the library incredibly than Ms's also dozens of times times faster, while small more than 10 times times.

After this I became particularly aware of the people who made the wheels--you have to think, if you need a plane wheel but the market only has bicycle wheels and the boss is urging you to do it, what can you do about it?

Fast string Matching

Mentioned earlier in the Microsoft internship when the boss threw me a Windows Phone let me study, I was playing at that time feel not quite right, find the contact person too troublesome.

For example, to find "Zhang Xiaoming", WP only support positioning to the Z-category-This means I need to be in the Z category of more than 70 contacts (surnamed Zhang surnamed Zhao's surname, etc.) inside the linear search, every time I need to slide four or five seconds to find the surname teenager.

This TMD is too stupid, Ben three years ago, the old broken Nokia support the initial positioning,996->zxm-> Zhang Xiaoming, directly fix, a new era of the Windows Phone is incredibly weak to this extent.

Search a little bit to find that there is no good dialer, so this cock directly with a support for the first letter matching dialer out to throw to the WP forum.

As a result, a variety of problems arise-the main reflection is that the speed is too slow, and some users even feedback buttons sometimes take half a second to react. This dick asked his address book size: About 3,000 people.

How can the groove have such a wonderful book of contacts, I realized that my string matching algorithm has a serious performance problem: Read everyone's name to calculate the pinyin, and then a match--the result if the number of contacts too much, the speed must be clumsy.

So I started to wonder if there was a high-end algorithm that could search multiple strings at the same time, so much so that two days on the subway were muttering about how to get this app to work faster.

Eventually, the answer was found in algorithms on Strings, Trees and sequences--there was a way to search for multiple strings simultaneously: Tries, and the book used a full chapter on how to get multiple string Comparison, I had a very high tide, and I was hooked.

Not much detail, in short, after changing the algorithm, matching speed is about 90 times faster, and the code is also short of dozens of lines. Even if there are 10,000 contacts, can also be done within 0.1 seconds, the speed bottleneck is so happy to be the algorithm.

Writing Efficient Programs

After doing a number of projects, more or less used the "home-made" algorithm or data structure, the most strangeness is to write a page in an ebook reader, I followed the principle of simulated annealing (simulated annealing) wrote a fast paging algorithm, in fact, the algorithm is really fast- But the problem is I don't know why it's so fast.

In short, the algorithm is a limited computing resources to play to the extreme of the weapon, when the computational resources are very abundant when the algorithm does not greatly use, but once the efficiency bottleneck algorithm cliff is the first sword (because the algorithm does not money!) Or have to change the CPU to buy SSD upgrade RAM, meat pain Ah!! )。 Some would argue that this is problematic because the human cost of writing a new algorithm is sometimes higher than the cost of adding hardware--but don't forget that increasing the efficiency of the hardware is also based on the scalable of the algorithm--or the algorithm.

Speaking of optimization here by the way writing efficient programs--hard to find a book about code optimization (I suspect that since Knuth said that premature optimization is the root of all evil, no one dares to write, the root of all evil, write it dry hair), note that this book is about code optimization- optimization without changing the architecture, algorithms, and hardware. While some of the book's trick, such as variable reuse or cyclic expansion, are obsolete, they are still a good book.


Internship internship on the second summer vacation, the next is the job-hunting season.

Job-hunting season when I have a sense of revenge----------------Before the interview I Was You black sky fly, this back to the job I want to put you one by one black back.

Now think back at that time of the psychological is stupid + naïve, but this dark psychology also played a certain positive role: I do not dare to have any neglect, so that at the end of May I began to prepare for a job interview, than the classmates around two months earlier than.

I didn't do the same thing as the classmates around me--I went on reading the code, because I thought the interviewer would never ask--in fact.

Algorithm Design Manual

Because many coding interview's forum all mentions this red book, I also follow the suit to make a copy. It turns out that the mere description of the part of the backtrack template is enough to value the get books back price, not to mention its heuristics and after-school questions.

Programming Zhu Ji Nanxiong & more programming Zhu Ji Nanxiong

These two books do not need to introduce more, programming Zhu Ji Nanxiong and more programming Zhu Ji Nanxiong, have not heard these two books please own wall. The former partial algorithm theory, the latter partial algorithm anecdote, the former Ascension ability, the latter growth conversation, are worth reading.

The Science of programming

Read about the correctness of binary search in the programming Zhu Ji Nanxiong, I was so hooked, the correctness of the original program can be deduced, and then I found in that chapter of the quote David Gries The science of the programming. Look at the name is very strong, directly engaged in a book open.

A book that deserves to be referenced by programming Zhu Ji Nanxiong, after the programming of the science, Ben gets the ability to prove the correctness of a simple code snippet--The second job interview kick.

Proving the correctness of a simple code snippet is a magical skill--because most companies in the interview require a piece of code on paper, and then the interviewer checks the code, and if you can prove that your code is correct, what can the interviewer be picky about?

Then is a variety of interviews, the details of the previous blog, in short, is the project experience, the paper code plus the correctness of this kick, Cuikulaxiu.


After the graduation season, after all sorts of happy,happy, this cock discovers another problem: insufficient algorithm capability.

Because later colleagues are said to be mostly ACM players, and this dick has never had an algorithmic race, and know the algorithm and data structures are very basic: such as those cellular automata, Fibonacci or line segment tree These high-end data structures can simply spell their English name, used to not use, so the psychological disturbed a force.

In order not to get into the job is despised too tragic, coupled with their usual algorithm inferiority, this cock force himself to learn the algorithm:

Algorithms 4th

Algorithms is my first book to revisit the algorithm, although it is actually a data structure of the introductory book, but it does fit the algorithm has been quickly forgotten the Ben-not for learning, only for the review.

The biggest highlight of the book is that it makes visualization and formatting the ultimate-maybe it's not the best data structure primer, but it's the best typesetting book I've ever read, a great way to read, and of course the content of the book is good, especially the red and black trees, I don't think there will be any books that are more clear than the book.

6.851 Advanced Data Structures

Advanced data Structures is MIT's high-level data structure tutorial, why did you find this tutorial? Because googleadvanced Data structures first came out of this goods.

This course contains a variety of strangeness data structures and algorithms that make this cock world view broken, including but not limited to:

    • Data structure with "memory" (data Structure with persistence).
    • Van Emde Boas (Inverse day of insertion, deletion, precursor and subsequent time complexity).
    • O (1) The time complexity of the LCA, RMQ and La solution.
    • The Magical O (n) time complexity of the suffix tree construction method.
    • O (LGLGN) of BST.
    • ...

In short, the climax, divided into high-energy, the only problem is not to achieve a lap. After this dick must find time to make them one after another.


From the contact algorithm to the present, about seven years: the first class to promote the algorithm of the theory, after the practice of advocating algorithm useless theory, after reading and then the reality to play back to the algorithm.

How so like the affirmation of dialectics to the negation and negation.

Now, a considerable number of advocates of algorithmic theory don't really understand the importance of algorithms-if you have no experience with algorithms to solve actual problems, how can you prove that algorithms are useful? And the vast majority of advocates of the algorithm useless people are just low-level yards of moan-they have never encountered the need to solve the problem with algorithms, naturally do not know how important the algorithm.

Peter Norvig once wrote a very wonderful SICP book review, which I think is still applicable to the SICP algorithm:

To a analogy, if algorithms were about automobiles, it would is for the person who wants to know how cars work, how t Hey is built, and how one might design fuel-efficient, safe, reliable vehicles for the 21st century. The people who hate algorithms is the ones who just want to know what to drive their car on the highway, just like Everyon E else.

MIT Professor Erik Demaine is more direct:

If you want to become a good programmer, you can spend years programming, or spend 2 years programming and learning ALG Orithms.

All in all, if you want to be a yard farmer or a skilled worker (code Monkey), you can not learn the algorithm, because the algorithm does not work for you, but if you want to be a good developer (Developer), a solid algorithm is necessary, Because you're going to fall into a hole that can only be crawled out of the algorithm.

A Google Programmer's algorithm learning path

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.