AlgoViz

Subsets (power set)

easy 15 min

The power set of a set is the set of all its subsets.

Where it shows up

The same pattern appears across everyday software.

  • Bitmask dynamic programming

    Route planners and schedulers that solve small travelling salesman or assignment problems store which stops or workers are used as a bitmask. The DP table has one row per subset, 2^n of them, which is why exact solutions stop at around 20 to 25 stops.

  • Feature flag and configuration testing

    A product with k on/off flags can run in 2^k configurations. Test suites enumerate every subset when k is small and switch to pairwise or sampled combinations when 2^k becomes too large.

  • Unix file permissions

    Read, write and execute are bits 4, 2 and 1. A permission set such as rw- is the subset {read, write}, stored as the number 6, and chmod 755 is three such subsets side by side.

  • Database query optimisation

    Classic join-order optimisers, such as the System R approach, use dynamic programming over subsets of the tables in a query, finding the best plan for every subset before combining them.

  • Market basket analysis

    Retail analytics looks for item sets bought together. The space of candidate item sets is the power set of the catalogue, so algorithms like Apriori prune it hard: a set can only be frequent if all of its subsets are.