Backtracking

Backtracking solves problems recursively by building a solution incrementally, one piece at a time and removing those solutions that fail to satisfy the constraints of the problem at any point of time.
Backtracking
Backtracking is an effective technique for solving algorithmic problems during interviews.

Critical steps in backtracking solution :

  • Construct a partial solution
  • Verify if the partial solution is valid or invalid
  • Verify if the solution is complete

How to determine if a problem can be solved using Backtracking? Every constraint satisfaction problem which has well-defined constraints can be solved by Backtracking. There are three types of problems which can be solved using backtracking :

  1. Decision Problem : Search for a feasible solution
  2. Optimisation Problem : Search for the best solution
  3. Enumeration Problem : Find all feasible solutions

Concepts and Problems - Backtracking
#TitleDifficultyCompanies

1.

The idea of Exhaustive Search

2.

Example 1 : Permutations

MEDIUM
Microsoft
Adobe
Google

3.

The Idea of Backtracking

4.

Example 1 : N Queen Problem

HARD
Amazon
Facebook
Qualcomm