My path to algorithmic learning

Source: Internet
Author: User
Tags explode

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 busy reselling all kinds of MP3 and headphones. For these courses are simply dismissive--anyway, the final exam is a key point can also be, so this whole computer science undergraduate most important course is stupid I directly ignore the past.

Until the junior I reacted to find a job later-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 I almost know nothing about the program, so I set myself a similar to the beginning of the founding of the five of the book Growth Plan, It contains books on the basis of C language, 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" to ask what algorithm books should be read, "seniors" are recommended algorithm introduction, 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 watercress this wonderful site, there is a lot of good quality reviews, so I put the evaluation of very high and look less scary computer books have been bought down-the fact that the watercress than these "seniors" or "Great God" It's much more reliable.

Data structure and algorithm analysis--c language descriptive narration

Data structure and algorithm analysis--c language description is my first book to learn the data structure: At that time there are a lot of places do not understand, so make the mark to repeat the look, the code is not clear. Then copied to the book to repeat the study, some of the algorithm can not get through, it all the middle state of the entire painting and then repeated 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 classic interview questions. 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 remember. To illustrate how important the algorithm is, this book takes the maximum subsequence and as a sample at the outset. All the way to 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 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.

With the knowledge I learned from this book-growing program, I managed to find a job that was something.

Entry

My internship is not practical to what algorithm (now seems to be piling up the existing API, write a bunch of themselves do not know the wrong 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. But I know this cliff is not the job I want 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 am pessimistic about the discovery whether it is my ability or diploma. are unable to meet the requirements of the Microsoft Institute. Contradictions. I completely overturned my "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 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 contented with--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: when the class rested outside and a few students asks smoking; Explain the algorithm sharp and unambiguous.

Although Han Jun never unsolicited mention, I'm sure the algorithm design and analysis based on his algorithm course in fact (de-facto) textbooks. His course structure is almost identical to the 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 there is also an algorithm book, and the ordinary algorithm book, the book from a creative point of view-assuming that the introduction of the algorithm is about what algorithms. So the introduction of the algorithm is about 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 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, 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 one has 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 not many projects in the group, the small piece I was responsible for was done in advance. Mentor was very generous to me a Kinect and a Windows Phone let me research, research, naturally there is no deadline. So I was a very 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 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 realization, then returned to the dorm quickly wrote a version number sent to Senior's mailbox. Turns out the other guy didn't have a bird.

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.

After a bitter lesson, I started the second "five". 37 Open time allocation becomes 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, the code in this book (or STL code) is really: fast, ruthless, quasi, Cologne master three elements of the whole.

C Interfaces and implementation

Baidu interview was burst 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 the traditional algorithm book, because their side weight is not the algorithm, but the classical algorithm detailed implementation (implementation). However, this is exactly what I need: because of the principle of the algorithm I can say clearly, but to give the elegant and concise implementation of the right I would be silly, even if it is Stof such a simple to explode "algorithm."

is still the old Fool study method: repeated reading + over and over again to copy the code to the book, after the difficult completion of these two books, and read a considerable number of programming practices (programming practice) books, self-feeling programming ability to greatly improve, and also acquire new skills-- Coded on paper .

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 can be used in addition to the interview. Other basic use, and even wrote a very complacent now read extremely silly articles to black those who are still "basic" or "internal strength" of the so-called "Daniel", here to get a piece of today seems very silly but then thought is the truth of the text:

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 program ape. At least in my opinion, what algorithm basic internal strength are bluffing, multi-point can use the practical program is the king, of course, if you are a pure theorist 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 documentation, I quickly discovered that SQL Reporting service was able to record T-SQL run statements and line numbers, so the 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 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.

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. 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, because I did not work for two months after the project. Every day leisurely tour Zai.

Phonetic index

The phonetic index is a small module in the reverse telecommuting of a mobile app I'm answering. The user expects the phone text box to be able to give smart hints based on the input:

For example, enter China:

Same, enter pinyin should also give a hint:

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, It looks like a 7000 or 8,000 item will crash. There are more than 20,000 standard Chinese characters. Nima.

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 between Chinese characters and pinyin--Chinese characters have multi-tone words. So need to put multiple 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, 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 even more than Ms dozens of times times faster. More than 10 times times smaller at the same time.

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

High-speed string matching

As mentioned earlier in the Microsoft internship, the boss threw me a Windows Phone let me study, I was playing at that time feel not quite right. It is too much trouble to find a contact person.

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 name of the boy.

This is so fucking stupid, Ben. Three years ago, the old broken Nokia support the first letter positioning. 996->zxm-> Zhang Xiaoming, directly fix, a new era Windows Phone unexpectedly will be 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, 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 groove be so wonderful in my address book, I realized that my string matching algorithm has a serious performance problem: Read all the names of people to calculate the pinyin, and then a match--the result assumes that 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 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 also uses a full chapter to say how to get multiple string comparison, see I was at that time climax repeatedly, straight call enjoyable.

Detailed details not much to say. After changing the algorithm, the matching speed is about 90 times faster, and the code is shorter by dozens of lines. Even if there are 10,000 contacts, it can be done within 0.1 seconds. The speed bottleneck is so enjoyable to be done by the algorithm.

Writing Efficient Programs

After doing a number of projects, more or less to use the "home-made" algorithm or data structure, the most strangeness is to write an e-book reader in the pagination, I follow the principle of simulated annealing (simulated annealing) wrote a high-speed paging algorithm, in fact, this algorithm is really 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 would argue that this is problematic, because the labor costs of writing new algorithms are 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 on the basis--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 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, 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 have to be introduced more. Programming Zhu Ji Nanxiong and a lot of other programming Zhu Ji Nanxiong. I have not heard of these two books, please wall yourself. The former partial algorithm theory, the latter partial algorithm anecdote. The former improves ability. The latter growth conversation is 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 is 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. The interviewer then examines the code, assuming you can prove that you are writing the correct code. What else can the interviewer be picky about?

Then there are all kinds of interviews. For details, see the previous blog, in short, 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 algorithm and data structures are very basic: like those cells of their own initiative, Fibonacci or segment tree These high-end data structures are simply able to spell their English names, Use it all. So the 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 primer for a data structure. But it really fits the fact that the algorithm has been forgotten for a while--not for learning. Just to relive.

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 book I've ever read, a great way to read, and, of course, the content of the book, especially the red and black trees, I don't think there will be any books that are clearer than this one.

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 world view broken, and 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, 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.

Summarize

From the contact algorithm to today, 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.

Today, a considerable number of advocates of algorithmic theory do not understand the importance of algorithms-assuming you have no experience in solving actual problems with algorithms. How can you prove that the algorithm is very useful? The vast majority of advocates of algorithmic uselessness are simply moan of low-level yards-they have never encountered a problem that needs to be solved with algorithms. Nature does not know how important the algorithm is.

Peter Norvig before wrote a very wonderful SICP book review, I think here to change the SICP algorithm is still applicable:

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 not practical for you, but suppose you want to be a good developer (Developer), a solid algorithm is indispensable. Because you're going to fall into a pit where you can just climb out with algorithmic talent.

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.