Skip to content

Commit 0c9af2c

Browse files
committedMar 14, 2019
Traveling Salesman and technical interviewing techniques.
1 parent 6fc9219 commit 0c9af2c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
 

‎7-case-studies/TravelingSalesman.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## TSP
2+
3+
Optimization problem. What's the fastest way for our salesman to get home given a graph?
4+
5+
Apparently this is used in microchip design and DNA sequencing.
6+
7+
## Category: NP-Hard
8+
9+
NP-Hard means known algorithm in polynomial time. That is, things like O(n^2), O(n), O(2).
10+
11+
## Two algo solution types
12+
13+
Exact, which will be in pseudo polynomial time.
14+
15+
Approximate, which will find a near-optimal solution in a quicker time (some of which are actually polynomial time!).
16+
17+
### Exact Algo
18+
19+
- Brute Force: Takes factorial time. O(n!)
20+
- Dynamic Programming:
21+
- Held-Karp Algorithm: O(n^2 * 2^n)
22+
23+
### Approximation Algo
24+
25+
- Christofides Algorithm: turns the graph into a tree, starting node is a root, and traverses through it in a way such that it guarantees that the result it finds is at most 50% longer than the shortest route.
26+
27+
- There exist some slight improvements on this algo, but the Christofides one is the main one.

0 commit comments

Comments
 (0)