Skip to main content

Backtracking with Pruning

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

What is Pruning? Pruning means detecting EARLY that a partial solution can never lead to a valid answer, and abandoning that branch immediately - instead of building it all the way out just to fail at the end. Every backtracking algorithm technically "works" without pruning, but pruning is what makes it FAST in practice, sometimes by orders of magnitude.

More lessons in Recursion & Backtracking