Resource · Guide or article
Power Set
Explains the power set and three ways to generate every subset, a direct match for 'return all subsets' interview problems.
Reviewed
Open the original: Power Set (opens the original site in a new tab)Add to a roadmap
Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.
Source content: English
Power set of a set S is the set of all of the subsets of S, including the empty set and S itself. Power set of set S is denoted as P(S). For example for {x, y, z}, the subsets are: Here is how we may illustrate the elements of the power set of the set {x, y, z} ordered with respect to inclusion:
PrepKit overview
PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.
- Suited to
- The source does not state a level
- Format
- Lesson
What it covers
- Why a set of n elements has 2^n subsets, using a 0 or 1 choice per element.
- Bitwise Solution: a table mapping numbers 0 to 7 to subsets of {a, b, c}.
- Backtracking Solution: add an element, recurse, remove it.
- Cascading Solution: start from the empty set and copy every existing subset with each new element added.
- Each method points to its file in the folder's JavaScript implementation.
How to use it
PrepKit study advice, not a claim made by the source.
Implement all three methods for [1, 2, 3], check each returns eight subsets, and explain which you would pick in an interview and why.
Scope and limitations
No time or space complexity is given for the individual methods, and there are no practice problems. Code is JavaScript.
Access and format
English README on GitHub next to bwPowerSet.js, btPowerSet.js, and caPowerSet.js; MIT-licensed trekhleb/javascript-algorithms; free.
Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88
Evidence behind this overview
- src/algorithms/sets/power-set/README.md
Pages that include this
Get the PrepKit newsletter
Optional. You don't need it to use PrepKit.