Tree pruning lets us cut branches off our state-space tree. The fewer branches, the faster the algorithm. We prune a branch when it’s clear that going into that branch would not yield a valid final state. This happens when the problem comes with one or more constraints, and the branches violates those contraints.
The difference between this and normal Backtracking are:
- We added a pruning step that checks if a branch is valid using
is_valid
- We increment
start_index
by a variable size instead of always 1