InterviewStack.io LogoInterviewStack.io

Recursion and Backtracking Questions

Recursive decomposition, base/recursive-case design, and backtracking search over combinatorial spaces (permutations, subsets, constraint satisfaction, N-queens style problems). Covers recursion-tree reasoning, pruning, and converting recursion to iteration. The conceptual bridge into dynamic programming and search.

HardTechnical
50 practiced

During a code review you find a candidate's recursive backtracking solution uses a mutable result list incorrectly and also lacks pruning, causing poor performance and incorrect outputs. Draft constructive feedback you would give, propose specific code changes, and outline a 4-week mentoring plan (exercises, readings, pair-programming) to help them master recursion/backtracking patterns.

MediumTechnical
39 practiced

Given a backtracking search that enumerates combinations summing to a target, describe three pruning techniques to reduce explored search space: sort+early-break, bound checks (prefix sums or lower bounds), and skip duplicates/frequency pruning. For each technique explain how it reduces branches and any added overhead to implement it.

MediumTechnical
55 practiced

Explain constraint propagation techniques used to accelerate CSPs and backtracking solvers: forward checking, arc consistency (AC-3), maintaining arc consistency (MAC), and MRV (minimum remaining values). For each technique describe algorithmic steps, how it prunes domains, and how to integrate it into a recursive backtracking solver. Illustrate with Sudoku or graph coloring.

HardTechnical
84 practiced

Rewrite a recursive Sudoku backtracking solver into an iterative implementation in C++ using an explicit stack for assignments and bitmasks for row/col/box availability. Signature: bool solveSudokuIterative(vector<vector<int>>& board). Explain what each stack frame stores, how you push/pop assignments, and how to compute next candidate cell efficiently (MRV heuristic).

HardTechnical
55 practiced

Convert recursive postorder traversal of a binary tree to an iterative implementation in Java without recursion. Provide signature: List<Integer> postorderTraversal(TreeNode root). You may use explicit stack(s) and markers; explain how you achieve postorder ordering, preserve O(n) runtime and O(h) space, and address edge cases for skewed trees.

Unlock Full Question Bank

Get access to all 41 Recursion and Backtracking interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.