Skip to content

Commit a1c4963

Browse files
committed
Add algorithm design tips (work in progress)
1 parent 9c494ad commit a1c4963

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Algorithm Design.markdown

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Algorithm design techniques
2+
3+
What to do when you're faced with a new problem and you need to find an algorithm for it.
4+
5+
### Is it similar to another problem?
6+
7+
One thing I like about [The Algorithm Design Manual](http://www.algorist.com) by Steven Skiena is that it includes a catalog of problems and solutions you can try.
8+
9+
If you can frame your problem in terms of another, more general problem, then you might be able to use an existing algorithm.
10+
11+
### It's OK to start with brute force
12+
13+
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.
14+
15+
Once you have a brute force implementation you can use that to verify that any improvements you come up with are correct.
16+
17+
And if you only work with small datasets, then a brute force approach may actually be good enough on its own.
18+
19+
### Divide and conquer
20+
21+
A big problem is often just a whole bunch of much smaller problems.
22+
23+
[More to come here]

README.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ This is a work in progress. More algorithms will be added soon. :-)
1616

1717
[Big-O notation](Big-O Notation.markdown). We often say things like, "This algorithm is **O(n)**." If you don't know what that means, read this first.
1818

19+
[Algorithm design techniques](Algorithm Design.markdown). How do you create your own algorithms?
20+
1921
[How to contribute](How to Contribute.markdown). Report an issue to leave feedback, or submit a pull request. **Suggestions and contributions are welcome!**
2022

2123
## Where to start?
@@ -130,6 +132,7 @@ Most of the time using just the built-in `Array`, `Dictionary`, and `Set` types
130132
- Red-Black Tree
131133
- Splay Tree
132134
- Threaded Binary Tree
135+
- [Segment Tree](Segment Tree/). Stores intervals and can answer which intervals (or segments) contain a given point.
133136
- kd-Tree
134137
- [Heap](Heap/). A binary tree stored in an array, so it doesn't use pointers. Makes a great priority queue.
135138
- Fibonacci Heap

0 commit comments

Comments
 (0)