Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Possible Duplicate:
Is it essential to learn algorithms to be a real programmer?

This question is, perhaps, related mostly to web developers who, like myself, code enterprise applications and use high level languages like Java, C# mostly.

Due to nature of enterprise web-apps, which essentially do CRUD operations, and since we rely heavily on libraries that the language provide, what is the significance of learning algorithms?

I know the web is filled with articles profoundly stating that "code is algorithm", but when was the last time anyone wrote quicksort algorithm in such an application?

I see far more benefits in learning Design patterns and anti-patterns, which are used a lot.

share|improve this question

migrated from stackoverflow.com Sep 23 '11 at 13:16

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Mark Trapp Sep 23 '11 at 20:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

8  
Algorithms are part of the design, no? Even if you don't write your own and use someone else's, you have to be able to reason why one particular algorithm is better than another for your operation. Similarly, picking the correct data structures (which again, you typically don't implement yourself) is also part of the design of the code. Patterns and architecture are macroscale, algorithms and data structures are smaller scale. –  birryree Sep 23 '11 at 13:16

8 Answers 8

up vote 18 down vote accepted

I see far more benefits in learning Design patterns and anti-patterns, which are used a lot.

From your point of view this is certainly true and many applications out there aren't really algorithm heavy. But a large amount of applications require a good knowledge about algorithms and datastructures, for example games or logistics applications. Those applications often require their very own algorithm for finding a shortest route or filling a knapsack, you can't just use a generic one.

I know the web is filled with articles profoundly stating that "code is algorithm", but when was the last time anyone wrote quicksort algorithm in such an application?

That's not the point. Most people aren't going to reimplement quicksort again. But quicksort demonstrates some of the most fundamental concepts of algorithm design. If you understand quicksort you can apply this sort of knowledge to other problems. As stated above, not all algorithms can be used generically. In the real world you often have to create custom algorithms for your problems, which are built with the same techniques that things like, for example, quicksort use.

And this can only be done with a fundamental knowledge about those algorithm techniques and data structures.

The one day you stumble across such a problem or a performance bottleneck in some routine, you'll be able to tackle it. And sooner or later there'll be one. I've seen CRUD developers who then simply said "It's not possible", when, in fact, it was pretty easily solvable.

share|improve this answer
    
Beside very basic sorting, searching, graph algorithm and data structures which algorithms are must for web developer to learn which are not taught in an university computer course. –  SIJAR Sep 23 '11 at 14:37
1  
@SIJAR - it depends on the domain. Now that we're in a world of big data and distributed systems, distributed algorithms (like things following the mapreduce algorithm pattern) are becoming increasingly more important and useful. If you're trying to analyze a lot of data to try and glean useful results, statistical/analysis algorithms like k-means clustering would be good to understand. If you're doing heavy text analysis and processing (like for searching), there are a broad category of algorithms for that too. In short, it really depends on what you're doing. –  birryree Sep 23 '11 at 14:51
1  
@SIJAR: This is a tough question. There're a few fundamental techniques you should learn which allow you to tacke any problem, divide and conquer for example. You specific domain does not matter so much. It'll make you a better developer, I promise. I'd advise you to read this excellent book: The Algorithm Design Manual. I wouldn't learn specific algorithms until I need them. The book has also got a catalogue of algorithms to choose from for specific problems. –  Falcon Sep 23 '11 at 14:54
1  
@birryee: I think he should learn the fundamentals first, then it's easier for him to understand any algorithm. –  Falcon Sep 23 '11 at 14:59
    
@Falcon - I do agree, I assumed he already would have a basic understanding of the fundamentals. The stuff I discussed is definitely a level above general algorithmic knowledge, and in many cases there is some custom algorithm implementation involved to fit your needs. –  birryree Sep 23 '11 at 15:21

In primary school I used to complain about learning math, as electronic calculators can do all the work — I thought.

What I want to say: As a developer you should always try to understand, how things work, instead of just excepting that they work — although you can rely on other developers work in 99.9% of all cases.

share|improve this answer

Being able to write a correct quicksort implementation is one level of knowledge. I sort of agree that it is rarely needed in the life of an average web developer (however, when you need it, you need it much).

Understanding how quicksort works (and being able to choose between it and other sorting algorithms for a specific task at hand) is another. I think this is more often needed, and a decent developer should have this level of general knowledge about fundamental algorithms. Without this, you don't even notice when you are in the situation that needs a specific algorithm - and this can have bad consequences.

Your question is a bit analogous to asking whether it is useful for a cab driver to enroll in a course practicing how to drive on snowy/icy road, since 99.9% of the cases this knowledge provides no benefit in the well kept roads of a big city. Indeed no - however in that 0.1% when it is needed, it may make a difference between a mild shock and a serious injury. And you may never predict in advance when you are going to need it!

Similarly to a taxi driver (or to any kind of craftsperson), we are also professionals who are supposed to know our tools of the trade. Software development is about problem solving, and failing to learn algorithms seriously reduces our problem solving power, thus our market value.

share|improve this answer
1  
Strongly agree with the "you won't even notice when you are in a situation..." sentiment. That is a particular kind of programmer, usually a younger one, that will tell you that they don't need a ton of specific programming knowledge because they could just Google it. In fact, they won't Google it because they won't know that there is something to be Googled, or what search term to use. –  PeterAllenWebb Sep 23 '11 at 17:15

When you use someone else's algorithm, you still need to understand the tradeoffs. For example, in Java, the sort() method provided by the Collections class uses a modified mergesort that guarantees n log(n) performance. However, it also states that it dumps the collection into an array, sorts the array, and iterates over the list. This use of an array requires more memory consumption.

The question becomes: Is this good enough for your needs? If you don't understand algorithms, time complexity, and space complexity, you can't really answer that. You don't need to know as much about the underlying mathematics and theory as someone who develops new algorithms, but you do need to be able to compare multiple algorithms and determine which one best allows you to meet the requirements of the system.

Note that the exact same thing applies to data structures. Understanding the characteristics of your data and the insert and retrieval from the data structure will allow you to choose the most appropriate structure for your needs.

Now, all of this happens at a lower level than design patterns. Design patterns say nothing about what data structure or algorithm that you need, but rather that you need to have some kind of relationship between modules of your application. When talking about design, you might say "we need to sort the data", or perhaps even "we need to provide multiple sorting algorithms" (Strategy pattern, perhaps?), but you wouldn't be talking about merge sort or quick sort or any particular sorting algorithms.

share|improve this answer

but when was the last time anyone wrote quicksort algorithm in such an application

It's like when was the last time someone redefined 2*2=4. Algorithm's for such problems has already been defined and redefined to the optimal solution. Hence, we don't need to write one for ourself. These sort of algorithm applies more to a system developer than a web developer.

code is algorithm

Definitely ,everything you write to achieve a task is an algorithm in itself. If you are achieving good results with your code, then you are performing good algo's. In case your application is slow in performing a function such as CRUD, then you need to think again and decide how to increase the performance. This is where algorithm comes in handy. It doesn't mean you need to R&D in Algorithms, but think in a rational manner as to how can you achieve the optimal performance for your function. Like deciding what sorting should be done before and after. Stuff's like that are more concerned to a web and application developer than quicksort and binarytree.

share|improve this answer

You have to learn how to understand and implement an algorithm, quicksort is just an example - right normally you will never write it yourself.

Sorting is a good example to learn that there are many different solutions for one problem, each with advantages and disadvantages depending on the data it works on.

Its is worthy to have some fundamental knowlegde of algorithms and complexity to avoid solutions like counting occurences just to check existance (just a simplified example).

share|improve this answer

If you only ever aspire to write the same web app for the rest of your career, and never wish to improve and expand your skillset, then their significance is limited. If you want to continue to learn, improve and expand your mind, knowledge and skills... that's another story. But it doesn't stop there, because you're wrong about one thing.

When you ask,

...when was the last time anyone wrote quicksort algorithm in such an application?

Once you're proficient, as happens when you learn design patterns... you start seeing them everywhere, even in places that were 'just code' before.

But even then... you're getting by just fine without them. Why are they important to know? They are important because there will come a time where a client makes a particular change request, or the company produces a new line of software, or you get a new job because you've got steady raises and a kid fresh out of school will be fine with the base salary, or you'll want to spread your horizons and work in a different field...

On that day, you will need this knowledge. On that day, that young pup fresh out of intro to algorithms isn't going to step up and say "move over Gramps, let the real devs work" - and be right.

share|improve this answer

I suspect you've been talking to front end designers! As a front-end designer, and following Falcon's comment, let me add "its not possible" is not something we wish to hear. In the complete picture non-pattern solution may be too costly, but it demands from programmers--to be competitive--an answer to the question, "Is this possible and if so how much?"

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.