N-Queens: Examples & Code
N-Queens: Place one queen per row; undo placements that block later rows. Stops at the first solution. Explore a worked example, complexity and tested code.
Explore algorithm visualizations code snippets and tutorials
N-Queens: Place one queen per row; undo placements that block later rows. Stops at the first solution. Explore a worked example, complexity and tested code.
Naive string matching: Try the pattern at every possible starting position. Explore a worked example, complexity and tested code.
Activity selection: Select the earliest finishing compatible activity. Explore a worked example, complexity and tested code.
Sieve of Eratosthenes: Mark multiples of each prime; unmarked values are prime. Explore a worked example, complexity and tested code.
Euclidean greatest common divisor: Replace (a,b) with (b,a mod b) until b is zero. Explore a worked example, complexity and tested code.