Skip to content

Latest commit

 

History

History
23 lines (12 loc) · 1.17 KB

Algorithm Design.markdown

File metadata and controls

23 lines (12 loc) · 1.17 KB

Algorithm design techniques

What to do when you're faced with a new problem and you need to find an algorithm for it.

Is it similar to another problem?

If you can frame your problem in terms of another, more general problem, then you might be able to use an existing algorithm. Why reinvent the wheel?

One thing I like about The Algorithm Design Manual by Steven Skiena is that it includes a catalog of problems and solutions you can try. (See also his algorithm repository.)

It's OK to start with brute force

Naive, brute force solutions are often too slow for practical use but they're a good starting point. By writing the brute force solution, you learn to understand what the problem is really all about.

Once you have a brute force implementation you can use that to verify that any improvements you come up with are correct.

And if you only work with small datasets, then a brute force approach may actually be good enough on its own. Don't fall into the trap of premature optimization!

Divide and conquer

A big problem is often just a whole bunch of much smaller problems.

[More to come here]