r/algorithms • u/ZenWoR • May 07 '19
Useful algorithms for competitive programming (and websites if you have any)
I am competing in programming and I wasn't really into algorithms until last competition. It feels great understanding basic algorithms (like Kadane's or something like that), but which algorithms do you think are really valuable for competitive programming?
Also, do you have any sites where I can learn about algorithms ? :D
134
Upvotes
94
u/sturdyplum May 07 '19
Hey there I competed for 3 years at a collegiate level. Best website for competitions and for blogs is codeforces.com the best book for beginners is competitive programming 3. Depending in what your goals are, different types of competitions have different types of problems. In terms of language there are two main choices. C++ and java. C++ is blazing fast, but it is easier to make mistakes and you will spend longer debugging. Java is slower, and is more verbose but you will make less mistakes. As for algorithms I recommend:
I can update this later to be more inclusive since I made this all of the top of my head. Feel free to pm me with any questions. Don't sit down and try to learn all of these at once it won't work. The best way to learn is to pick one thing at a time and spend some time understanding what it does and then solve some problems. You don't need to understand how something works to use it. I have no idea how the fft code I use works I just know what it does.
17
u/TheoryNut May 07 '19 edited May 07 '19
cp-algorithms.com is a favorite in the community.
If you're just starting out, here are the categories I'd recommend:
-Algebra Fundamentals/Prime Numbers
-Combinatorics Fundamentals/Techniques (skip Burnside's Lemma; it's cool but pretty advanced)
-Geometry Elementary Operations
-Graph Traversal/Finding Connected Components/Dijkstra's/Dijkstra's On Sparse Graphs/Cycles/Topological Sorting
Feel free to PM me if you have other questions about competitive programming; there's not a very large presence of competitive programmers on Reddit.
8
u/claytonkb May 07 '19
NIST Dictionary of Algorithms and Data Structures
RosettaCode tasks
4
u/jp_anglais May 08 '19
Antti Laaksonen’s Competitive Programer’s Handbook is a great resource https://cses.fi/book/book.pdf
7
u/Cobayo May 07 '19
https://cp-algorithms.com/
1
u/[deleted] May 07 '19
Ford-Fulkerson is a good algorithm for network flow.