Skip to content
Tech Interview Prep home
Technical interview guide

Backtracking

Recursive brute-force search with early pruning — build a partial solution, and abandon it the moment it can't possibly work.

Read
42 min
Practice MCQs
25
Interview QA
25
Edition
v7
Editorial status
Reviewed

Scope: Language-neutral, with generator and recursion behaviour cited from CPython 3.14.

Interview QA

Treat each question like a live interview question: answer out loud first (structure, assumptions, tradeoffs), then open the model answer to spot gaps and rehearse a tighter follow-up.

Curated: · Written: · Reviewed:

QA-1

Explain backtracking as a search over a decision tree and how it changes a production decision.

QA-2

How would you reason about the choose-explore-unchoose shape in a system you own?

QA-3

Walk through the base case, including where engineers most often get it wrong.

QA-4

What does pruning is the whole point guarantee, and what does it deliberately leave open?

QA-5

Describe constraint propagation and the evidence you would collect before relying on it.

QA-6

A teammate proposes a design that hinges on ordering the choices. How do you evaluate it?

QA-7

Where does generating subsets matter, and where is it irrelevant?

QA-8

Teach generating permutations to an engineer who has only seen it as a rule of thumb.

QA-9

The input array can contain duplicate values. How do you generate all subsets without producing duplicate subsets?

QA-10

Why does combination generation thread a start index through the recursion instead of tracking used elements the way permutation code does?

QA-11

What would you measure before treating reuse of elements as settled?

QA-12

How does the N-queens formulation change if the workload grows by two orders of magnitude?

QA-13

Given a 2D grid of characters and a target word, how do you search for a path of horizontally or vertically adjacent cells that spells the word without reusing a cell, and why must the mark be undone on the way back?

QA-14

When would you refuse a design because of memoisation versus backtracking?

QA-15

How would you explain counting versus enumerating without using the usual slogan?

QA-16

When does a backtracking search need to copy its path or board instead of mutating in place and undoing, and what does each choice cost in time and memory?

QA-17

When does recursion depth become a failure mode in a backtracking search, and how would you detect it and fix it with depth limits, bounding the search, or an explicit stack?

QA-18

How do you decide a problem calls for backtracking rather than greedy, dynamic programming, or plain enumeration?

QA-19

When would you run iterative-deepening DFS instead of plain DFS or BFS when the solution depth is unknown, and what does it cost?

QA-20

What trade-off does symmetry breaking force that a junior answer usually skips?

QA-21

How does branch and bound prune a combinatorial search, and what makes a bound strong enough to actually cut work?

QA-22

When a backtracking search has an exponential worst case, when is shipping it the right call and when do you refuse? Walk me through the reasoning.

QA-23

How does testing a backtracking solution interact with rollback, and where do people ignore that?

QA-24

How does backtracking solve the Hamiltonian Cycle problem, and how do you prune paths that cannot visit all vertices?

QA-25

How do you implement Word Search on a 2D grid using backtracking and in-place visited tracking?