What are the 10 algorithms one must know in order to solve most algorithm
- Sieve of Eratosthenes, or another prime number sieve
- Depth-first search
- Breadth-first search
- Dijkstra's algorithm
- Floyd--Warshall algorithm
- Either Kruskal's or Prim's algorithm
- Some implementation of topological sorting, such as by using DFS
- Convex hull (I recommend the Monotone Chains algorithm)
- Coordinate compression
- Edmonds--Karp, or another implementation of the Ford--Fulkerson method; or a preflow-push algorithm; or, if you are preparing an ACM codebook, Dinic's algorithm. (Note: Max flow is not allowed to appear on the IOI, but may nevertheless appear on national team-selection contests)
challenges/puzzles?搞定编程竞赛必知哪10个算法?
其中最重要的有范围树(Range Tree,也被称为线段树或区间树)和树状数组(BITs),也被称作Fenwick树。除此之外,许多DP算法使用了一个前缀和数组(prefix sum array)。
1.Eratosthenes筛法,或另一种素数筛法
2.深度优先搜索
3.广度优先搜索
4.Dijkstra算法
5.Floyd–Warshall 算法
6.Either Kruskal算法 或称 Prim算法
7.一些拓扑排序的实现,比如使用DFS
8.凸包(我推荐单调链算法)
9.坐标压缩
10.Edmonds–Karp,或者Ford–Fulkerson方法的另一种实现;亦或预流推进算法;又或者,如果你在准备ACM codebook,那么就Dinic算法。(注意:最大流不允许出现在国际资讯赛中,尽管如此,它也可能会出现在国家队选拔赛中。)