Algorithms and Data Structures · Middle · Question 48 of 75
How many subsets does a set of n elements have, and why does that matter?
- ✓Correct answer: 2ⁿ, so generating all subsets is exponential
- 2n!, so generating them all is factorial
- 3n², so generating them all is quadratic
Explanation
Each element is either in or out, giving 2ⁿ combinations. Backtracking that enumerates subsets is fine for n around 20 but not 50. n! is the number of permutations.