Everything on the site.

Big-O notationAlgorithms · Count the steps in real loops, then compare n, n log n, n² and 2ⁿ on a live chart.RecursionAlgorithms · Watch frames push and pop on the call stack for factorial and Fibonacci.BFS vs DFSAlgorithms · A queue against a stack: draw a graph and see which order each search visits it in.Sorting algorithmsAlgorithms · Seven sorts on the same input, with comparison, swap and write counts side by side.Binary searchAlgorithms · Halve the range, probe the middle, repeat: with lo, mid and hi drawn on the array.Sets, relations and functionsDiscrete maths · Shade any set expression on a Venn diagram and test a relation for its properties.Proof by inductionDiscrete maths · Four worked proofs revealed one step at a time, and a broken one to diagnose.CombinatoricsDiscrete maths · An exact nPr and nCr calculator, and a Pascal’s triangle that shows its own addition rule.Boolean algebraDiscrete maths · The laws, De Morgan, and normal forms, with a truth-table generator built in.Finite-state machinesTheory · Build a DFA in a table, see it drawn, and run strings through it one symbol at a time.Domain theoryTheory · Why recursion needs least fixed points, and how CPOs, Scott continuity and powerdomains supply them.Truth table generatorTools · Expression in, truth table out: with DNF, CNF, a minimal form and LaTeX.Graph traversal visualiserTools · Draw a graph, then animate BFS, DFS and Dijkstra with the frontier shown.Recursion tree visualiserTools · Paste a recursive function or a recurrence and see its call tree and call count.Gradient descentML maths · Drag the starting point, set the learning rate, and watch it converge or blow up.Vectors and embeddingsML maths · Bend the plane with a 2×2 matrix and measure how close toy word vectors are.Softmax and cross-entropyML maths · Edit the logits and watch the probabilities, the loss and the gradient update live.Attention mechanismML maths · Q, K and V for three tokens, a live score heatmap, and the weighted sum of values.Image to video attentionML maths · One photo, 16 frames: switch reference attention on or off and watch the colours hold or drift.Formatting a CS paper in LaTeXLaTeX · Page limits, \documentclass, front matter, theorem environments and the bibliography.Camera-ready checklistLaTeX · Fonts embedded, PDF/A, copyright form, source bundle, and why final versions get rejected.LaTeX templatesLaTeX · Where the official classes live, plus a minimal article template you can copy.Boolean algebra calculatorTools · A Boolean expression simplifier that names the law used at every step.K-map solverTools · Fill in a Karnaugh map and see the groups, the minimal SOP and POS, and the essential terms.Logic gate simulatorTools · Wire up gates, flip the switches, and get the truth table and expression of your circuit.Regex to NFA converterTools · Type a regular expression and watch Thompson’s construction build its NFA, fragment by fragment.NFA to DFA converterTools · Enter an NFA or a regex and step through the subset construction, then minimise the DFA.DFA simulatorTools · Edit a DFA, run strings through it step by step, batch-test them and share the machine as a link.Regular expressions to automataTheory · Regex to NFA to DFA to minimal DFA, worked through on one example with every set shown.The halting problemTheory · Why no program can tell whether every program halts, with the paradox program played out.Pigeonhole principleDiscrete maths · n pigeons, k holes: why some hole gets ⌈n/k⌉, and the surprising things that follows from it.Dijkstra’s algorithmAlgorithms · Shortest paths with a priority queue: a worked table, a proof, and a graph you can redraw.Hash functionsAlgorithms · Keys in, buckets out: hash a word four ways, then watch chaining and probing handle collisions.Sorting algorithm visualizerTools · Up to seven sorts race on the same data, then step through any one of them line by line.LaTeX table generatorTools · Type or paste a table, merge cells, pick booktabs, and copy clean tabular code.Combination calculatorTools · Exact nCr with the cancelling shown, combinations with repetition, and a full list for small n.Permutation calculatorTools · nPr, nʳ, anagrams like MISSISSIPPI and round-table seatings, with exact working.AVL tree visualizerTools · Insert, delete and search, then replay every balance factor and rotation step by step.IEEE 754 converterTools · Decimal to float bits and back, with the exact stored value and why 0.1 isn’t exact.Two’s complement calculatorTools · Signed integers to bits and back, with the working, other encodings and overflow checks.Power set calculatorTools · Every subset of your set, sorted by size or bitmask, with 2ⁿ counted exactly.Huffman coding calculatorTools · Text or frequencies in, Huffman tree and codes out, with every merge shown in order.LaTeX matricesLaTeX · pmatrix, bmatrix, augmented and large matrices, each with copyable code and its result.AlgorithmsSection · Step-through visualisations of sorting, searching, recursion, graph traversal, Dijkstra’s algorithm, hash functions and Big-O growth, with pseudocode that follows along.Discrete mathsSection · Sets, relations and functions, proof by induction, counting, the pigeonhole principle and Boolean algebra, explained with worked examples and interactive checkers.TheorySection · Finite-state machines, regular expressions and automata, the halting problem, and the mathematical semantics of programming languages, explained from first principles.ML mathsSection · Gradient descent, vectors and embeddings, softmax, attention and image to video models, each with a formula, a worked numeric example and a live version.ToolsSection · Free browser tools: truth tables, K-maps, logic gates, nCr, power sets, regex to DFA, sorting, graph and AVL tree visualisers, IEEE 754, two’s complement and Huffman codes.LaTeXSection · How to format a CS conference or workshop paper in LaTeX, a camera-ready checklist, a minimal template you can adapt, and how to typeset matrices.
Free tool

Power set calculator: list every subset of a set

The power set of a set S is the set of all its subsets, including the empty set and S itself. Type a set to list every subset, grouped by size or in binary counting order, with the count 2ⁿ worked out exactly. You can copy the result as plain text or LaTeX.

Interactive: Power set lister with size filter, bitmask view and LaTeX outputUpdated

Power set calculator

The subsets

Subsets by size

Size kC(n, k)

What a power set is

For a set SS, the power set P(S)\mathcal{P}(S) (also written 2S2^S) is the set whose elements are all the subsets of SS:

P(S)={ A:A⊆S }.\mathcal{P}(S) = \{\, A : A \subseteq S \,\}.

For S={a,b,c}S = \{a, b, c\}:

P(S)={∅, {a}, {b}, {c}, {a,b}, {a,c}, {b,c}, {a,b,c}}.\mathcal{P}(S) = \bigl\{ \emptyset,\ \{a\},\ \{b\},\ \{c\},\ \{a,b\},\ \{a,c\},\ \{b,c\},\ \{a,b,c\} \bigr\}.

Two members are easy to forget. The empty set ∅\emptyset is a subset of every set, because it has no element that could fail to be in SS. And SS itself is a subset of SS. The subsets other than SS are called proper subsets.

The elements of a power set are sets, not elements of SS. So {a}∈P(S)\{a\} \in \mathcal{P}(S) but a∉P(S)a \notin \mathcal{P}(S), and ∅∈P(S)\emptyset \in \mathcal{P}(S) as well as ∅⊆P(S)\emptyset \subseteq \mathcal{P}(S). Mixing up ∈\in and ⊆\subseteq here is the most common mistake in exercises.

Why a set of n elements has 2ⁿ subsets

To build a subset, go through the elements one at a time and decide: in or out. Each element has 2 choices, independently of the others, so by the product rule there are

∣P(S)∣=2×2×⋯×2⏟n=2n|\mathcal{P}(S)| = \underbrace{2 \times 2 \times \cdots \times 2}_{n} = 2^{n}

subsets, of which 2n−12^n - 1 are proper. The count doubles with every element you add, because each old subset appears twice in the new power set, once without the new element and once with it. That doubling is also an induction proof: ∣P(∅)∣=1=20|\mathcal{P}(\emptyset)| = 1 = 2^0, and adding an element turns 2n2^{n} into 2n+12^{n+1}. See proof by induction for the general method.

n01234510203064
2ⁿ subsets1248163210241,048,5761,073,741,82418,446,744,073,709,551,616

The calculator counts exactly for sets of up to 1,000 elements and lists the subsets for up to 12 elements (4,096 subsets). Beyond that, any list is too long to read.

Counting subsets of each size

The number of subsets with exactly kk elements is the binomial coefficient (nk)\binom{n}{k}, the number of ways to choose kk of the nn elements. Adding over all sizes counts every subset once, which gives the identity

∑k=0n(nk)=2n.\sum_{k=0}^{n} \binom{n}{k} = 2^{n}.

For {a,b,c}\{a, b, c\} the sizes 0, 1, 2, 3 have 1, 3, 3, 1 subsets: row 3 of Pascal’s triangle. The table beside the calculator shows the row for your set, and “Show” can restrict the list to one size. To count subsets of one size for large nn, use the combination calculator.

Subsets as binary numbers

Number the elements 0, 1, 2, … and represent a subset by an nn-bit number whose bit ii is 1 exactly when element ii is in the subset. Counting from 0 to 2n−12^n - 1 then visits every subset exactly once. For {a,b,c}\{a, b, c\}, with aa as bit 0:

MaskBits (c b a)Subset
0000∅
1001{a}
2010{b}
3011{a, b}
4100{c}
5101{a, c}
6110{b, c}
7111{a, b, c}

This is the standard way to generate a power set in code:

function powerSet(items) {
  const result = [];
  for (let mask = 0; mask < (1 << items.length); mask++) {
    result.push(items.filter((_, i) => mask & (1 << i)));
  }
  return result;
}

It takes O(n⋅2n)O(n \cdot 2^n) time, which is optimal since the output itself has that many element slots. Choose “Binary counting order” in the calculator to see the mask beside each subset. The same bijection explains why bitmasks are used for sets of flags, and why brute-force search over subsets (for example, trying every subset in the subset-sum or knapsack problem) becomes impractical around n=40n = 40.

Properties worth knowing

  • A⊆BA \subseteq B implies P(A)⊆P(B)\mathcal{P}(A) \subseteq \mathcal{P}(B).
  • P(A∩B)=P(A)∩P(B)\mathcal{P}(A \cap B) = \mathcal{P}(A) \cap \mathcal{P}(B), but only P(A)∪P(B)⊆P(A∪B)\mathcal{P}(A) \cup \mathcal{P}(B) \subseteq \mathcal{P}(A \cup B): the subset {a,b}\{a, b\} of {a}∪{b}\{a\} \cup \{b\} is in neither power set on the left.
  • P(∅)={∅}\mathcal{P}(\emptyset) = \{\emptyset\}, which has one element, and P(P(∅))={∅,{∅}}\mathcal{P}(\mathcal{P}(\emptyset)) = \{\emptyset, \{\emptyset\}\}, which has two.
  • Ordered by ⊆\subseteq, a power set is a Boolean lattice: union and intersection play the roles of OR and AND, and complement plays NOT. That is why the laws on the Boolean algebra page hold for sets too.
Cantor’s theorem For every set SS, finite or infinite, P(S)\mathcal{P}(S) is strictly larger than SS. Given any function f:S→P(S)f : S \to \mathcal{P}(S), the set D={x∈S:x∉f(x)}D = \{x \in S : x \notin f(x)\} can’t equal any f(x)f(x), so no function hits every subset. The power set of the natural numbers is therefore uncountable, and the same diagonal idea proves the halting problem undecidable.

Using the calculator

  • Separate elements with commas (red, green, blue) or spaces (1 2 3). Braces are optional. Elements can be words, numbers or symbols; repeated elements are counted once, as in any set.
  • Group by size lists subsets from the empty set up to SS, each size in lexicographic order of the elements as you typed them. Binary counting order lists them by bitmask, with the first element as the lowest bit.
  • LaTeX notation writes \emptyset and \{a, b\}, ready to paste into a document; the copy button copies the whole power set. For typesetting tips see the LaTeX guides.

Background on sets, relations and functions, with a Venn diagram you can shade, is on the sets, relations and functions page.

References

  1. K. H. Rosen, Discrete Mathematics and Its Applications, 8th ed., McGraw-Hill, 2019. Section 2.1 (power sets) and Section 6.4 (binomial coefficients).
  2. P. R. Halmos, Naive Set Theory, Van Nostrand, 1960. Section 5, complements and powers.
  3. D. E. Knuth, The Art of Computer Programming, Volume 4A: Combinatorial Algorithms, Part 1, Addison-Wesley, 2011. Section 7.2.1.1, generating all n-tuples.