Recursion · 2 of 3
Recursive brute force
Try every combination of choices with one decision per call: list the subsets with a shared list, return a count or a best value, and loop over more than two options.
Books1
Links2
- Complete Search with Recursion Subsets by recursion and by bit masks on Apple Division, permutations on Creating Strings, and backtracking on Chessboard and Queens, with practice problems. usaco.guide (opens in a new tab)
- Algorithms, Chapter 2: Backtracking Searches that make one decision per call, on n queens, game trees and subset sum, and what each call has to know about the decisions before it. Parts of this page adapt this chapter's text, licensed CC BY 4.0 (creativecommons.org/licenses/by/4.0), with changed wording, examples and code. jeffe.cs.illinois.edu (opens in a new tab)