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.

So every time I get an interview, I get simple problems. The problem is, I seem to make a mess of it by writing inefficient algorithms that either take too much space or time. I am really not able to break down a problem into smaller parts and solve it using algorithms I would have used before.

Is there a reference (book or website) that describes the best practices and approaches of algorithm design? What about that resource makes it special?

What is your background? If you have a computer science or math degree then CLRS or similar books would be fine. Otherwise an lightweight introduction to algorithms would be good. –  Lasse Espeholt Apr 20 '11 at 16:14
@lasseespeholt: i have a computer science degree –  yahh Apr 20 '11 at 16:15
@yahh Okay, then CLRS could be good to read. And supplement it with ProjectEuler and pages with more diverse exercises so you learn to use them. –  Lasse Espeholt Apr 20 '11 at 16:19
Brute force isn't a bad place to start, as it gives you a reference to compare your algorithm with both for performance and correctness. –  hammar Apr 20 '11 at 16:19
You have a CS degree or are pursuing a degree? Because not to be bearer of bad news but a CS degree should include algorithm design topics. Not saying you should be able to on a whim implement dijkstra's algorithm but you should understand basic loop complexities various search algorithms. –  Chris Apr 20 '11 at 17:39
comments disabled on deleted / locked posts

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

migration rejected from stackoverflow.com Sep 23 '13 at 15:21

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by gnat, MichaelT, Dan Pichelman, Kilian Foth, Ozz Sep 23 '13 at 15:21

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – gnat, MichaelT, Dan Pichelman, Kilian Foth, Ozz
If this question can be reworded to fit the rules in the help center, please edit the question.

4 Answers

Programming Challenges by Steven S. Skiena and Miguel Revilla is a pretty good book for practising this sort of thing.

would you mind explaining more on what it does and what it's good for? "Link-only answers" are not quite welcome at Stack Exchange –  gnat Apr 14 '13 at 7:34
add comment

I learnt most of the coolest algorithms from internet only. I guess a good staring point is CLRS. You can also try these:

Personally I Algorithm Design to be a very good book but CLRS is an encyclopedia.

add comment

Yes, as others have said: brute force and naive is a perfectly good start. Working is better than non-working.

After that, consider and optimize. Sometimes you'll need to try a completely different approach (good luck with that), and sometimes it's just plain hard.

There's really not that much algorithmic sophistication in the real world (at least, the part of it that I live in), so those interview questions are kind of BS.

add comment

As @hammar said, brute force is a good place to start. In general, what sort of unlocked the subject for me was thinking in terms of information flow. To me, that makes it easy to classify algorithms and suggests how to make up new ones.

add comment

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