Bitmasks represent sets: bit indicates element membership.
TSP example: dp[mask][i] = min cost visiting cities in mask, ending at .
for mask from 0 to 2^n - 1:
for last in mask:
for next not in mask:
newMask = mask | (1 << next)
dp[newMask][next] = min(dp[newMask][next],
dp[mask][last] + dist[last][next])
Time: . Space: . Feasible for .