Competitive Programming Syllabus
Note that in general, the syllabus for Competitive Programming is open-ended. For ACM ICPC, the syllabus is not mentioned anywhere, whereas IOI syllabus is specified before the start of the contest each year. The below syllabus is kind of detailed topics from which you may face questions in competitive programming related competitions.
Geometry
- Graham Scan algorithm for Convex Hull O(n * log(n))
- Suggested Reading: https://www.geeksforgeeks.org/convex-hull-set-2-graham-scan
- Monotone Chain algorithm for Convex Hull O(n * log(n)) (This is easier to implement than Graham Scan)
- Online construction of 3-D convex hull in O(n^2)
- Sample Implementation: https://gist.github.com/msg555/4963794
- Bentley Ottmann algorithm to list all intersection points of n line segments in O((n + I) * logn)
- Suggested Reading - http://softsurfer.com/Archive/algorithm_0108/algorithm_0108.htm
- Rotating Calipers Technique
- Suggested Reading - http://cgm.cs.mcgill.ca/~orm/rotcal.html
- Problems - Refer the article for a list of problems which can be solved using Rotating Calipers technique.
- Line Sweep/Plane Sweep algorithms
- Area/Perimeter of Union of Rectangles.
- Closest pair of points.
- Suggested Reading - http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=lineSweep
- Problems - Follow the tutorial for list of problems.
- Area of Union of Circles.
- Problems - http://www.spoj.com/problems/CIRU/
- Delaunay Triangulation of n points in O(n * logn).
- Voronoi Diagrams of n points in O(n * logn) using Fortuneâs algorithm.
- Point in a polygon problem -
- O(n) solution without preprocessing.
- O(logn) algorithm with O(n * logn) preprocessing for convex polygons.
++ Sample Implementations of these routines can be seen here: https://gist.github.com/msg555/7207431
- Problems on computational geometry -
- BSHEEP, BULK, SEGVIS, CONDUIT, RUNAWAY, DIRVS, RAIN1, SHAMAN, TCUTTER, LITEPIPE, RHOMBS, FSHEEP,
FLBRKLIN, CERC07P, BAC, ALTARS, CERC07C, NECKLACE, CH3D, RECTANGL, POLYSSQ, FOREST2, KPPOLY,
RAIN2, SEGMENTS, ARCHPLG, BALLOON, CIRCLES, COMPASS, EOWAMRT, ICERINK on SPOJ. - CultureGrowth, PolygonCover on Topcoder.
- BSHEEP, BULK, SEGVIS, CONDUIT, RUNAWAY, DIRVS, RAIN1, SHAMAN, TCUTTER, LITEPIPE, RHOMBS, FSHEEP,
- Suggested Reading - Computational Geometry: Algorithms and applications. Mark De Burg.
String Algorithms
Substring search
- KnuthMorrisPratt algorithm (Problems - NHAY, PERIOD on SPOJ)
- Suggested Reading - Cormen chapter on Strings.
- http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=stringSearching
- Aho Corasick algorithm
- Problems - WPUZZLES on SPOJ
Suffix Arrays
- O(n^2 * logn) Naive method of suffix array construction
- O(n * logn^2) method of suffix array construction
- O(n * logn) method of suffix array construction
- O(n) method of suffix array construction
- O(n) LCA preprocess on Suffix Arrays to solve a variety of string problems
Suffix Trees
- O(n) construction of Suffix trees using Ukkononâs algorithm
- O(n) construction of Suffix Trees if provided with Suffix Arrays using Farachâs algorithm
Other
- Suffix Automata - O(n) Suffix Automaton construction.
- Dictionary Of Basic Factors - O(n * logn) method of DBF construction using Radix Sort.
- Manacherâs algorithm to find length of palindromic substring of a string centered at a position for each position in the string.
Runtime -> O(n). - Searching and preprocessing Regular Expressions consisting of â?â and â*â
Multi-dimensional pattern matching
- DISUBSTR, PLD, MSTRING, REPEATS, JEWELS, ARCHIVER, PROPKEY, LITELANG, EMOTICON, WORDS, AMCODES, UCODES, PT07H, MINSEQ, TOPALIN, BWHEELER, BEADS, SARRAY, LCS, LCS2, SUBST1, PHRASES, PRETILE on SPOJ
- http://www.algorithmist.com/index.php/Category:String_algorithms
Graphs
Basic Graphs
- Representation of graphs as adjacency list, adjacency matrix, incidence matrix and edge list and uses of different representations in different scenarios
- Breadth First Search (Problems - PPATH, ONEZERO, WATER on SPOJ)
- Depth First Search
- Strongly Connected Components (TOUR and BOTTOM on SPOJ)
- Biconnected Components, Finding articulation points and bridges (RELINETS, PT07A on SPOJ)
- Dijkstra algorithm (SHPATH on SPOJ)
- Floyd Warshall algorithm (COURIER on SPOJ)
- Minimum Spanning Tree (BLINNET on SPOJ)
- Flood-fill algorithm
- Topological sort
- Bellman-Ford algorithm.
- Euler Tour/Path (WORDS1 on SPOJ)
- Suggested reading for most of the topics in Graph algorithms -
http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=graphsDataStrucs1. - Also refer to the tutorial for problems concerning these techniques.
- Cormen chapter 22 to 24.
Flow networks/ matching
- Maximum flow using Ford Fulkerson Method
- Suggested Reading - http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=maxFlow
- problems - TAXI, POTHOLE, IM, QUEST4, MUDDY, EN, CABLETV, STEAD, NETADMIN, COCONUTS, OPTM on SPOJ.
- Maximum flow using Dinicâs Algorithm (PROFIT on spoj)
- Minimum Cost Maximum Flow.
- Successive Shortest path algorithm.
- Cycle Cancelling algorithm - http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=minimumCostFlow1
- Maximum weighted Bipartite Matching (Kuhn Munkras algorithm/ Hungarian Method)
- problems - GREED, SCITIES, TOURS on SPOJ | http://www.topcoder.com/stat?c=problem_statement&pm=8143
- Stoer Wagner min-cut algorithm.
- Hopcroft Karp bipartite matching algorithm (ANGELS on SPOJ)
- Maximum matching in general graph (blossom shrinking)
- Gomory-Hu Trees (MCQUERY on Spoj)
- Chinese Postman Problem
- problems - http://acm.uva.es/archive/nuevoportal/data/problem.php?p=4039
- Suggested Reading - http://eie507.eie.polyu.edu.hk/ss-submission/B7a/
- Suggested Reading for the full category ->
- Network flow - Algorithms and Applications by Ahuja
- Cormen book chapter 25.
Dynamic Programming.
- Suggested Reading - Dynamic Programming(DP) as a tabulation method
- Cormen chapter on DP
- Standard problems (you should really feel comfortable with these types)
- State space reduction
- Solving in the reverse - easier characterizations looking from the end
- Counting/optimizing arrangements satisfying some specified properties
- Strategies and expected values
- DP on probability spaces
- DP on trees
- http://www.topcoder.com/stat?c=problem_statement&pm=10800
- http://www.topcoder.com/stat?c=problem_statement&pm=10737
- http://www.topcoder.com/stat?c=problem_solution&rm=266678&rd=10958&pm=8266&cr=7581406
- DP with data structures
- http://www.spoj.pl/problems/INCSEQ/
- http://www.spoj.pl/problems/INCDSEQ/
- http://www.spoj.pl/problems/LIS2/
- http://www.topcoder.com/stat?c=problem_statement&pm=1986
- Symmetric characterization of DP state
- A good collection of problems
Greedy
- Chapter on Greedy algorithms in Cormen
- http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=greedyAlg
- Problems - refer to the topcoder tutorial.
Number Theory
Modulus arithmetic
- Basic postulates (Including modular linear equations, Continued fraction and Pellâs equation)
- Suggested Reading -
- Chapter 1 from Number Theory for Computing by SY Yan (Recommended)
- 31.1, 31.3 and 31.4 from Cormen
- www.topcoder.com/tc?module=Static&d1=tutorials&d2=primeNumbers
- Problems
Fermatâs theorem, Euler Totient theorem (totient function, order, primitive roots)
- Suggested Reading
- 1.6, 2.2 from Number Theory by SY Yan
- 31.6 , 31.7 from Cormen
- Problems
Chinese remainder theorem
- Suggested Reading
- 31.5 from Cormen
- 1.6 from Number Theory by SY Yan
- Problems
- Project Euler 271
- http://www.topcoder.com/stat?c=problem_statement&pm=10551&rd=13903
Primality tests
- Deterministic O(sqrt(n)) approach
- Probabilistic primality tests - Fermat primality test, Miller-Rabin Primality test
- Suggested Reading -
- http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=primalityTesting
- Cormen 31.8
- 2.2 from Number Theory by SY Yan
- Problems
- PON, PRIC, SOLSTRAS on SPOJ
- http://www.topcoder.com/stat?c=problem_statement&pm=4515
- Prime generation techniques - Sieve of Erastothenes (PRIME1 on SPOJ)
GCD using euclidean method
- Suggested Reading - 31.2 Cormen
- Problems
Logarithmic Exponentiation
- Suggested Reading - http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=primalityTesting
Integer Factorization
- Naive O(sqrt(n)) method
- Pollard Rho factorization
- Suggested Reading
- 2.3 from Number Theory SY Yan
- 31.9 Cormen
- Problems -
Other
- Stirling numbers
- Wilson theorem
- nCr % p in O§ preprocess and O(log n) query
- Lucas Theorem
- Suggested Reading for Number Theory -
- Number theory for computing by Song Y Yan (Simple book describing concepts in details)
- Concepts are also superficially covered in Chapter 31 of Introduction to Algorithms by Cormen
- http://www.codechef.com/wiki/tutorial-number-theory
- http://www.algorithmist.com/index.php/Category:Number_Theory
- Problems on Number Theory -
Math (Probability, Counting, Game Theory, Group Theory, Generating functions, Permutation Cycles, Linear Algebra)
Probability
- Basic probability and Conditional probability
- Random variables, probability generating functions
- Mathematical expectation + Linearity of expectation
- Special discrete and continuous probability distributions
- Bernoulli, Binomial, Poisson, normal distribution
- http://acm.sgu.ru/problem.php?contest=0&problem=498
- Suggested Readings
- Cormen appendix C (very basic)
- Topcoder probabilty tutorial http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=probabilities
- http://en.wikipedia.org/wiki/Random_variable
- http://en.wikipedia.org/wiki/Expected_value
- William Feller, An introduction to probability theory and its applications
Counting
- Basic principles - Pigeon hole principle, addition, multiplication rules
- Problems
- Suggested readings
- Inclusion-exclusion
Special numbers
- Stirling, eurlerian, harmonic, bernoulli, fibonnacci numbers
- http://en.wikipedia.org/wiki/Stirling_number
- http://en.wikipedia.org/wiki/Eulerian_numbers
- http://en.wikipedia.org/wiki/Harmonic_series_(mathematics)
- http://en.wikipedia.org/wiki/Bernoulli_number
- http://en.wikipedia.org/wiki/Fibonnaci_numbers
- Concrete mathematics by Knuth
- Suggested problems
Advanced counting techniques - Polya counting, burnsides lemma
- Suggested reading
- Problems
Game theory
- Basic principles and Nim game
- Sprague grundy theorem, grundy numbers
- Suggested readings
- Suggested problems
- Hackenbush
- Suggested problems
Linear Algebra
Matrix Operations
- Addition and subtraction of matrices
- Cormen 28.1
- Multiplication (Strassenâs algorithm), logarithmic exponentiation
- Cormen 28.2
- Linear Algebra by Kenneth Hoffman Section 1.6
- Problems
Matrix transformations (Transpose, Rotation of Matrix, Representing Linear transformations using matrix)
- Suggested Reading - Linear Algebra By Kenneth Hoffman Section 3.1,3.2,3.4,3.7
- Problems
- Determinant, Rank and Inverse of Matrix (Gaussean Elimination , Gauss Jordan Elimination)
- 28.4 Cormen
- Linear Algebra by Kenneth Chapter 1
- Problems
Solving system of linear equations
- Suggested Reading
- 28.3 Cormen
- Linear Algebra by Kenneth Chapter 1
- Problems
Using matrix exponentiation to solve recurrences
- Suggested Reading
- Problems
Eigen values and Eigen vectors
Polynomials
- Roots of a polynomial (Prime factorization of a polynomial, Integer roots of a polynomial, All real roots of a polynomial)
- http://www.topcoder.com/stat?c=problem_statement&pm=8273&rd=10798
- POLYEQ , ROOTCIPH on Spoj
- Lagrange Interpolation
Permutation cycles
- Suggested Reading - Art of Computer Programming by Knuth Vol. 3
- Problems - ShuffleMethod, Permutation and WordGame on topcoder.
Group Theory (Advanced Techniques)
- Burnside Lemma
- Polyaâs theorem
- Suggested Reading
- Hernsteinâs topics in algebra
- Problems
- TRANSP on spoj
- http://www.topcoder.com/stat?c=problem_statement&pm=9975
Generating functions
- Suggested Reading
- Herbert Wilfâs generating functionology
- Robert Sedgewick and Flajouletâs Combinatorial analysis
Data Structures
Basic
- Arrays/Stacks/Queues
- Problems
- Reading:
- CLRS: section 10.1
- http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=dataStructures
Singly/Doubly Linked List
- Problems - https://www.spoj.pl/problems/POSTERS/
- Reading: CLRS: section 10.2, Mark Allen Weies Chapter 3
Hash Tables
- Problems
- Reading: CLRS: Chapter 11, Mark Allen Weies Chapter 5
Circular linked list / queue
- Problems - https://www.spoj.pl/problems/CTRICK/
Binary/n-ary trees
- Reading
- CLRS: section 10.4
- CLRS: Chapter 12
- Mark Allen Weies Chapter 4
- http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=binarySearchRedBlack
Heaps
- Problems
- Reading : Mark Allen Weies Chapter 6
Trie
- Reading: https://threads-iiith.quora.com/Tutorial-on-Trie-and-example-problems
- Problems
Interval trees / Segment Trees
Fenwick (Binary Indexed) trees
- Problems - https://www.spoj.pl/problems/MATSUM/
- Reading - http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=binaryIndexedTrees
Disjoint data structures
- Problems
- Reading:
- http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=disjointDataStructure
- Mark Allen Weies Chapter 8
Range minimum Query (RMQ)
Customized interval/segment trees (Augmented DS)
- Problems
- Reading: CLRS: Chapter 14 (augmented DS)
AVL Trees
- Problem - https://www.spoj.pl/problems/ORDERS/
Miscellaneous
- Splay Trees
- B/B+ Trees
- k-d Trees
- Red-black Trees
- Skip List
- Binomial/ Fibonacci heaps
Exercices
- https://www.spoj.pl/problems/LAZYPROG/ (Hint: Heaps)
- https://www.spoj.pl/problems/HELPR2D2/ (Hint: Interval Trees)
- https://www.spoj.pl/problems/SAM/ (Hint: Heaps)
- https://www.spoj.pl/problems/PRHYME/ (Hint: Trie)
- https://www.spoj.pl/problems/HEAPULM/ (Hint: Interval Trees)
- https://www.spoj.pl/problems/CORNET/ (Hint: Disjoint)
- https://www.spoj.pl/problems/EXPAND/
- https://www.spoj.pl/problems/WPUZZLES/
- https://www.spoj.pl/problems/LIS2/
Persistent Segment Tree
- https://blog.anudeep2011.com/persistent-segment-trees-explained-with-spoj-problems/
- Problems: COT, MKTHNUM on SPOJ.
Centroid Decomposition
- Tutorial links:
- Problems:
Heavy Light Decomposition
Search Techniques/Bruteforce writing techniques/Randomized algorithms.
Backtracking (beginner)
- N queens problems
- Knights Tour
- Sudoku Problem
- Tiling Problem
- 15 puzzle.
Dancing Links and Algorithm X given by Knuth (advanced)
- problems - PRLGAME, SUDOKU, NQUEEN on SPOJ
- Suggested reading - http://www-cs-faculty.stanford.edu/~uno/papers/dancing-color.ps.gz
Binary Search (beginner)
- problems - AGGRCOW on SPOJ. Refer the tutorial for more problems.
- finding all real roots of a polynomial using binary search (intermediate)
- Suggested Reading
Ternary Search (intermediate)
- Problems
- http://www.spoj.pl/problems/KPPOLY/
- http://www.codechef.com/DEC09/problems/K1/
- http://www.topcoder.com/stat?c=problem_statement&pm=4705&rd=7993
- http://www.topcoder.com/stat?c=problem_statement&pm=7741&rd=10671
- http://www.topcoder.com/stat?c=problem_statement&pm=6464&rd=9994
- http://www.topcoder.com/stat?c=problem_statement&pm=3501&rd=6529
- http://www.topcoder.com/stat?c=problem_statement&pm=4567&rd=6539
Meet in the middle (Intermediate)
- Tutorial: http://www.infoarena.ro/blog/meet-in-the-middle
- problems - http://www.spoj.pl/problems/MAXISET
Hill Climbing (Advanced)
- This is used for optimization problems where finding optimal solution is hard.
Simulated Annealing (Advanced)
- Similar to previous, this is another technique for solving problems where finding optimal solution is hard.
- Tutorial: https://apps.topcoder.com/forums/?module=Thread&threadID=696596&start=0&mc=11#1324862
Regular Iteration to reach a fixed point (Advanced)
- Newton-Raphson method to find root of a mathematical function.
- Iterations to solve linear non homogeneous system of equations.
Representing sets with bitmasks and manipulating bitmasks (Beginner)
- Suggested Reading - http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=bitManipulation
- problems - refer to the tutorial link in Suggested reading section.
General programming issues in contests
- Arithmetic Precision (Beginner)
- Suggested Reading - http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=integersReals