Backtracking Algorithms Flashcards
Backtracking Algorithms
Backtracking is a technique for solving problems by exploring all possible solutions and removing those that do not satisfy the problem constraints. Examples include solving the N-Queens Problem and Sudoku Solver.
N-Queens Problem
The N-Queens Problem is a classic puzzle that involves placing N chess queens on an N×N chessboard so that no two queens threaten each other. In other words, no two queens can share the same row, column, or diagonal. Solving this problem requires finding all possible solutions or configurations of queens on the board that satisfy these constraints.
Sudoku Solver
The Sudoku Solver is an algorithmic problem that involves filling a 9×9 grid with digits (usually from 1 to 9) so that each column, each row, and each of the nine 3×3 subgrids (called “regions” or “boxes”) contain all of the digits without repetition. Solving this problem entails finding a valid solution for the partially filled grid.
Combination Sum
The Combination Sum problem involves finding all possible combinations of numbers in an array that add up to a specific target sum. It may involve using each number in the array multiple times or only once, depending on the variant of the problem. Backtracking is often used to find these combinations efficiently.