TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

What are the 10 algorithms one must know

6 点作者 carlosgg超过 10 年前

2 条评论

artmageddon超过 10 年前
Top three answers for those who don&#x27;t want to sign up with Quora:<p>Dynamic Programming appears to account for a plurality (some estimate up to a third) of contest problems. Of course, DP is also not a single algorithm that you can just learn once and retain, so maybe this doesn&#x27;t answer your question.<p>I suppose it also depends on whether you consider data structures in the same category as algorithms. There are certainly some data structures that you should be familiar with if you want to do well in programming competitions. The most important ones are range trees (variously known as interval trees or segment trees) and binary indexed trees (BITs), also known as Fenwick trees. Additionally, many DP algorithms make use of a prefix sum array.<p>The most essential of the single algorithms I can think of are the following, in no particular order. However, you may be disappointed by how rarely some of these actually appear in contests. Most non-DP problems appear to be of the &quot;ad hoc with data structures&quot; variety, and you simply have to practice in order to get good at them.<p>(To be clear, again, I list below only algorithms that take a single input set, compute some function of it, and carry no state between inputs. This distinguishes them from data structures, which by definition hold state, and categories of algorithms and algorithmic techniques like DP, which don&#x27;t have some specific function they compute.) · Sieve of Eratosthenes, or another prime number sieve · Depth-first search · Breadth-first search · Dijkstra&#x27;s algorithm · Floyd--Warshall algorithm · Either Kruskal&#x27;s or Prim&#x27;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&#x27;s algorithm. (Note: Max flow is not allowed to appear on the IOI, but may nevertheless appear on national team-selection contests)
评论 #8572671 未加载
评论 #8572741 未加载
timbrah超过 10 年前
Is there any way to read this without wasting time clicking through things Quora wants you to click through?<p>I&#x27;m interested in this answer, but not in setting up accounts and interests just to read it.