Data Structures & AlgorithmsVery hard

When enumerating subsets, what is the total count of non-empty subsets of an n-element set?

  1. A. 2^n
  2. B. n(n+1)/2
  3. C. 2^n − 1
  4. D. n!

Correct answer: C. 2^n − 1

Each element is either in or out (2^n choices), and removing the empty subset leaves 2^n − 1. The other formulas count ordered arrangements or subarrays instead.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic