Recursion
Function calling itself to solve problems by breaking them into smaller instances
Backtracking
Exploring all possible solutions and abandoning paths that don’t work
Dynamic programming
Optimizing recursive solutions by storing and reusing previously computed results
Gauss sum
Mathematical formula for quickly summing consecutive integers
When to use these techniques
Recursion
Recursion
Use recursion when a problem can be broken down into smaller, similar subproblems. Common use cases include tree traversal, factorial calculation, and divide-and-conquer algorithms.
Backtracking
Backtracking
Use backtracking for constraint satisfaction problems where you need to explore all possible solutions, such as puzzle solving, pathfinding, and combinatorial optimization.
Dynamic programming
Dynamic programming
Use dynamic programming when you have overlapping subproblems and optimal substructure. Common applications include fibonacci sequences, shortest paths, and optimization problems.
Gauss sum
Gauss sum
Use the Gauss sum formula when you need to quickly calculate the sum of consecutive integers without iterating through them.