My path to algorithmic learning

Source: Internet
Author: User

About

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

If you are using a mobile phone or tablet device, then click on the link below to get a better reading result:

http://zh.lucida.me/blog/on-learning-algorithms/

Original Lucida

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.
Beginner

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.

It wasn't until the junior I reacted that I had to find a job--and the sophomore toss proved that I didn't have any business talent. In the future still have to rely on code bread where eat. I was horrified to find myself almost ignorant of the programming. So I set myself a reading growth plan similar to that of the early five, which contains books on C language Foundation, data structure and computer network.

The first step in a book plan is to choose a book. I have to the time I think very cattle "seniors" and "great God" consulted should read which algorithmic books, "seniors" are recommended algorithm introduction, there are several "big God" recommended computer programming art (now I suspect they have turned over these books), hastily turned over these two books found really do not understand. But fortunately I stumbled on the watercress this wonderful site, there are a lot of good quality reviews, so I put the evaluation of very high and seemingly not so scary computer books have been bought down-the fact that the watercress than these "seniors" or "great God" more reliable.

Data structure and algorithm analysis--c language descriptive narration

Data structure and algorithm analysis--c language description is the first book I Study data structure: At that time there are a lot of places do not understand, so make the mark repeated to see, the code is not clear, so copied to the book repeated study; some algorithms do not make sense, it all the middle state and then repeat the deduction. It turns out that while such learning methods look 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.

So far, I remember, this book to illustrate how important the algorithm is, at the outset take the largest subsequence and as a sample, the complexity from O (n^3) to O (n^2) to O (NLGN) and finally to O (N). At that time really is the admiration of the feeling like the surging river, why can this cock.

In addition, I was also in the book before the algorithm of the data structure of the whole hand to beat. Later to find an internship is quite complacent to put this thing on the resume, now think of really silly force without limit.

Learn the lessons learned from this book growth program. I finally found a better job, this is something.

Entry

My internship is not practical to what algorithm (now seems to be piling up the existing API.) Write a bunch of code that you don't know about, and I've been working with people around me for a couple of years to do the same thing. I started getting restless. 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

At this moment of wavering. Microsoft's DreamWorks became the last straw to overwhelm the camel, and the book's description of Microsoft Research Asia made me the "job-seeking company". However, I was pessimistic to find that regardless of my ability at the time or diploma, can not meet the requirements of the Microsoft Institute, under the contradiction, I completely overturned their "graduate work" idea. Quit your internship and prepare for the grind.

The details do not need to repeat the examination, but still clearly remember that they were surprised and excited during the second-round examination of the Beihang dormitory is the Microsoft Sigma building opposite. The feeling of being one step closer to the ideal was a blast.

Algorithm Design and analysis

My graduate career is definitely a negative example-skipping classes. Practice. Write water paper, do water research, but one thing I am quite complacent--from beginning to end listened carefully to Professor Han Jun's algorithm design and analysis course.

Han Jun gave me the deepest impression of two points: when the class rested outside and a few students asks smoking; Explain the algorithm sharp and unambiguous.

Although Han Jun never actively mentioned it, I am sure that the algorithm design and analysis is based on his algorithm course (de-facto) textbook, because his curriculum structure almost the same as the organization structure of the book.

hypothesis data structure and algorithm analysis--c language descriptive narrative is my data structure enlightenment, then the Korean Army's Curriculum and algorithm design and analysis 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 what I inadvertently read at this time there is an algorithm book, and the ordinary algorithm book is different. This book from a creative point of view-assuming that the introduction of the algorithm is about what the algorithm, then the introduction of the algorithm is how to create the algorithm.

Combining 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 a fortuitous coincidence, I entered the Microsoft Asia Project Institute Internship. One step closer to the ideal, self-feeling unlimited.

Consolidate

The Internship at Microsoft Project Academy was a very, very important turning point in my graduate school stage:

    1. Made a small project that also said the past.

    2. During the period of Baidu internship interview frustrated. Read a lot of programming books from the bitter background.
    3. Microsoft's internship experience has become one of the few highlights of my resume (this one has no grades, two no papers.) Three no ACM).

1 and 3 are not mentioned here (and not on the subject of this article). The point is that 2.

Since there were no particularly many projects in the group. The small piece that I was in charge of was done in advance, and mentor was very generous to throw me a Kinect and a Windows phone to let me study. Study well, naturally there is no deadline, so I was very chicken thief of the time 37 open: Seven minutes Daoteng windows Phone, three-point reading & 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 good sparkle shine, so I took a look at the domestic IT environment + abuse of the interviewer's abnormal psychology cast a resume, the results in the first side on his brother burst: he let me write a stof(string to float). I grind haw half a day did not write the complete implementation, and then back to the dorm to write a version number sent to my brother's mailbox, the result is no bird me.

This has been a very big 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 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 think the name with "Elements of" is cool and fried days of the book, so I almost did not hesitate to buy this Elements of programming, in fact, this book code (or STL code) is really: fast. Hard. Quasi, Cologne master three elements of the whole.

C Interfaces and implementation

Baidu interview was burst into the experience let me realize that there is still a problem, most companies need to write C code on paper, and I myself very few C (in most cases in C #), considering that they have not been able to let the company change the interview process to the point. I need to improve my ability to write C code (even for interviews only).

After a Google meal. I locked the C Interfaces and implementation--, and there's an odd book about how to write the C code of the crazy, cool, hot-fried day, and here's what Amazon's comments are: Probably the best advanced C books in Existance.

Strictly speaking, the above two books are not traditional algorithm books, because they are not the weight of the algorithm. But the detailed implementation of the classic algorithm (implementation). But this is exactly what I need: because of the principle of the algorithm I can say clearly, but to give the elegance of the correct concise implementation of my stupid. Even a simple to explode "algorithm" such as Stof .

Still the old fool. Learning methods: Repeat reading + Copy the code to the book over and over again. After the difficult completion of these two books, and read a considerable number of programming practices (programming practice) books, self-feeling programming ability and greatly improved. In addition to acquiring new skills-- on paper coding . It also became one of the kick that I was looking for for a job interview.

Application

To tell the truth, since the undergraduate internship, I have always thought 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 is a piece of text that looks very silly today but is believed to be true at the time:

So the move is what the algorithm AH basic ah, so-called Daniel. Please close your mouth, all roads pass Rome.

The algorithm is not a prerequisite for programming. Mathematics does not prevent a person from becoming a good program ape. At least in my opinion, what algorithm base internal strength are bluffing of the thing, multi-point can use the practical program is kingly. Assuming, of course, that you are a pure theorist, when I say nothing.

But the interesting thing is. It didn't take long to write this article. 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.

A simple look at the SQL Server related documentation. I quickly discovered that SQL Reporting service was able to record T-SQL run statements and line numbers. The line coverage was done, but the boss said the line coverage was too naive and we needed a more realistic block coverage.

After reading the definition of block overlay. I found that I needed to parse the T-SQL without finding a good T-SQL parser. You can only do one yourself:

More strangeness, when I was doing this project I just took ANTLR author's language implementation patterns half, what ll (k) Ah Packrat Ah, the concept of AST Walker is warm.

So. Himself as the official EBNF of T-SQL, rinsed the LL (k) Parser of a T-SQL stored procedure. Convert the code into an AST and then use 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.

The old nature is very agreeable-I suspect his plan was to spend two or three months to finish the project. I didn't work for two months after the project, leisurely tour Zai every day.

Phonetic index

The phonetic index is a small module in the mobile app reverse telecommuting that the user expects to be able to give smart hints based on the input in the Phone text box:

For example, enter China:

Same. Enter pinyin should also give a hint:

Chinese match this simple. But the pinyin match takes time to think about it--I didn't bother to build the wheel. I found the Pinyin Library of Microsoft in the first time. 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 Limited, seemingly 7000 or 8,000 item will collapse, and the standard Chinese characters have more than 20,000, and so on.

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 (seemingly 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, two points + displacement unpack are used. Directly to the search from Chinese characters to pinyin.
    5. Later, the performance of small measurement, the speed is 50 times times more than the original library of MS, and the code is only 336 lines.

The user is very happy--because I took the polyphone he had not thought of, and the smooth force.

I am also very happy, because I did not expect to write the library is dozens of times times faster than MS, more than 10 times times smaller than the same time.

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

High-speed string matching

Mentioned earlier in the Microsoft internship when the boss threw me a Windows Phone let me study. I did not feel right when I was playing and it was too much trouble to find the contact person.

For example, find "Zhang Xiaoming". WP only supports 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 name of the boy.

This TMD is too stupid, Ben three years ago, the old broken Nokia support the first letter positioning,996->zxm-> Zhang Xiaoming. Just take care of it. A new era Windows Phone should be weak to this extent.

I found a little bit of a dial-up program. So this dick just went straight to a support for the first letter matching the dialer out to throw to the WP forum.

As a result, there were immediate problems--the basic response was that it was too slow, and some users, even the feedback buttons, sometimes had to react in half a second. This dick asked his address book size: About 3,000 people.

How can The spit groove have such a wonderful directory. I realized that there was a serious performance problem with my string matching algorithm: Read all the names of the people to calculate the pinyin, and then a match--the result assumes that the number of contacts is too much, the speed must be clumsy.

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

Finally, in algorithms on Strings, Trees and sequences found the answer-there is a way to search for multiple strings at the same time: Tries, and this book is a full chapter on how to get multiple string Comparison, I saw a climax. It's a straight call.

Detailed details not much to say, in short, after changing the algorithm. The matching speed is about 90 times faster. And the code is dozens of lines shorter.

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

A number of projects were then made. More or less, "homemade" algorithms or data structures are used. The most strangeness is to write a page in an ebook reader. I wrote a high-speed paging algorithm according to the principle of simulated annealing (simulated annealing), which is actually very fast--but the problem is I don't know why it's so fast.

Anyway. 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 have much use, but once to 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 people would argue that this is a problem. Because the labor cost of writing a new algorithm is sometimes higher than the cost of adding hardware--but don't forget to add hardware to improve the efficiency is also based on the algorithm is scalable---plainly or the algorithm.

Speaking of optimization here by the way writing efficient programs--is very difficult to find a book about code optimization (I suspect 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-optimizations that do not change the architecture, algorithms, and hardware. While some of the book's trick, such as variable reuse or cyclic expansion, are obsolete, the whole is still a good book.

Improve

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

Job-hunting season I have a sense of revenge---------------before the interview of Baidu Internship I Was you black sky. This time to apply for a job I want to put you all Black back, a.

Now I recall the psychology of the time is stupid + naïve. But this kind of 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 did not like the students around the brush problem--but continue to read the code algorithm, because I think those rare and outrageous questions interviewer will not ask-in fact, so.

Algorithm Design Manual

Since there are so many coding interview forums that mention this red book, I have followed suit.

It turns out that. Just about backtrack template that part of the descriptive narrative is enough to value the get books back price, let alone its heuristics and after-school questions.

Programming Zhu Ji Nanxiong & A lot of other programming Zhu Ji Nanxiong

These two books do not need to introduce more, programming Zhu Ji Nanxiong and many other 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 that I was able to deduce the correctness of the program, and then I found David Gries's the science of programming in that chapter's citation.

Look at the name and think it's very powerful. Directly engaged in a book open.

A book that deserves to be referenced by programming Zhu Ji Nanxiong. After the science of programming. This is the skill that proves the correctness of the simple code snippet --The second kick of the job interview.

proving the correctness of a simple code snippet is a fantastic skill--because most companies in the interview require a piece of code to be written on paper, then the interviewer checks the code. Suppose you can prove yourself that the code you wrote is correct, what can the interviewer be picky about?

Then there are all kinds of interviews. See the previous blog for details. In short is the project experience , the paper code plus correctness proves this kick, Cuikulaxiu.

Evolution

After the graduation season is a variety of happy,happy after this dick found that there is a problem: the ability of the algorithm is insufficient.

Since later colleagues are said to be mostly ACM players. And this dick has never had an algorithmic race, and know the algorithms and data structures are very basic: like those cells of their own initiative, Fibonacci heap or line segment tree These high-end data structures are simply able to spell out their English names, used to no use, so psychological disturbed by a force.

In order not to get into the job is discriminated against too dire, coupled with their usual algorithmic 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. Just to relive.

The biggest highlight of the book is that it has made 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. The reading experience is a great force. Of course, the content of this book is also good, especially the red and black tree part, I think there will be no more than this book is more clear.

6.851 Advanced Data Structures

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

This course contains a variety of strangeness data structures and algorithms that make this cock a world view. They contain, but are not limited to:

    • Data structure with "memory" (data Structure with persistence).
    • Van Mode Boas (Inverse day insertion, deletion, precursor and successor 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. The only disadvantage is that they do not achieve a lap. After this dick must find time to make them one after another.

Summarize

From the contact algorithm to today, about seven years: the first class of praise algorithm theory. After the practice of advocating algorithm useless theory, after reading and then by 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 people who preach algorithmic theory don't understand the importance of algorithms-assuming you have no experience with algorithms to solve actual problems, how can you prove that algorithms are very useful? And the vast majority of advocates of the algorithm useless people are just low-level code farmers moan-they have never encountered the need to solve the problem with the algorithm, naturally do not know how important the algorithm.

Peter Norvig has written a wonderful SICP book review before. I think it's still useful to change the SICP into an 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, suppose you want to be a yard farmer or a skilled worker (code Monkey), you can not learn the algorithm, because the algorithm is really not practical for you. But suppose you want to be a good developer (Developer), a solid algorithm is indispensable, because you will continue to fall into some only with the help of algorithmic ability to climb out of the pit.

Above.

by Lucida

My path to algorithmic learning

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.