VFlash: Fast, Accurate Visual Planning via Flash Primitive Decoding
u_Unrolled
DSA for AI/ML · Module 08: Recursion and backtracking

Lesson 8.3 of 10 in this module Unrolled Pro

Subsets

Generate every subset of n distinct items: 2^n of them, so the output size is the floor. From counting through bitmasks, to doubling a list of subsets item by item, to backtracking with a start index, and a generator that yields one subset at a time in O(n) memory. Then subsets of exactly size k with pruning, the best feature subset under a cost budget with bound-based pruning, deciding subset sums for n = 30 with meet in the middle, and random subsets when enumeration is out of reach.

about 10 min 5 Python examples 2 quick checks

Problem. Given a list nums of distinct integers, return all possible subsets (the power set), in any order.

text
nums = [1, 2, 3]   →   [], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]

Each item is either in or out: 2ⁿ subsets, each up to n long. Any method must produce Θ(n · 2ⁿ) output, so "optimising" here means three different things: not doing much more than that, using little memory beyond the output, and, in the constrained versions, not generating subsets you'll throw away.

ML context. Subsets of features, of data sources, of ensemble members, of augmentations: "which combination works best?" is a subset search. Real versions come with constraints (a cost budget, a fixed size), and the art is pruning whole families of subsets at once (Changes A and B). Past n ≈ 25, exhaustive search is out and you split the problem or sample (Changes C and D).


1. Step 1: Clarify

That's the preview. Modules 00–01 are free; this lesson is part of Unrolled Pro.
Staff AI & Pro Tier Lesson

Unlock "Subsets"

The foundations are free forever. Unrolled Pro unlocks the complete lesson, production architectures, and 55 battle-tested ML system design case studies.

Everything included with Pro:
All 234+ Deep-Dive Lessons across transformer internals, inference, RAG & agents
55 Staff-Level ML & System Design Case Studies with mathematical capacity estimates
AI Engineer Sheet & Exercises with worked solutions, self-checks, and code
100 Landmark Research Papers guided walkthroughs & progress tracking
14-Day Money-Back Guarantee — 100% full refund if you aren't satisfied
View Plans & Unlock All Lessons

From ₹167/mo (~$2/mo) · Cancel anytime · Instant activation

100% Risk-Free: 14-day no-questions-asked money-back guarantee