Skip to main content

Constraint Satisfaction

Learn Constraint Satisfaction (Recursion & Backtracking, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

What is a Constraint Satisfaction Problem (CSP)? A CSP asks: assign a value to each of several VARIABLES, from their respective DOMAINS, such that every CONSTRAINT between variables is satisfied. Sudoku, N-Queens, and graph coloring are all CSPs - backtracking is the general-purpose algorithm for solving them: assign a value, check constraints, recurse; undo and try another value if stuck.

More lessons in Recursion & Backtracking