AI InterviewSearch…Search problems, topics, or pages…Ctrl KGet started
Mediumsubsets

~60s

Selecting at least one item

In how many ways can one or more items be selected from 5 distinct items?

Show the answer and the worked solution

Correct answer: B.

31

Worked solution

  1. Each of the 5 items may be included or excluded: 2⁵ = 32 subsets.
  2. Exclude the empty selection: 32 − 1 = 31.

Answer: 31.

The idea

The number of non-empty subsets of n items is 2ⁿ − 1. Forgetting to subtract the empty set gives 32.

Shortcut. Write each selection as a 5-bit in/out string: they run from 00001 to 11111, which is 1 to 31 in binary, so there are 31 non-empty selections.

Common trap. "32" — counting all 2⁵ subsets and forgetting that one of them is the empty selection, which 'one or more' rules out.

Permutations & Combinations

23 of 35

Level

Medium

Target time

~60s

Selecting at least one item — Aptitude Question

Selecting at least one item: In how many ways can one or more items be selected from 5 distinct items? Answer and worked solution on CodeKairo.

Question

In how many ways can one or more items be selected from 5 distinct items?

Options

  1. 25
  2. 31
  3. 32
  4. 120
Show the answer and the worked solution

Correct answer: B. 31

Worked solution

  1. Each of the 5 items may be included or excluded: 2⁵ = 32 subsets.
  2. Exclude the empty selection: 32 − 1 = 31.

Answer: 31.

The idea

The number of non-empty subsets of n items is 2ⁿ − 1. Forgetting to subtract the empty set gives 32.

Shortcut. Write each selection as a 5-bit in/out string: they run from 00001 to 11111, which is 1 to 31 in binary, so there are 31 non-empty selections.

Common trap. "32" — counting all 2⁵ subsets and forgetting that one of them is the empty selection, which 'one or more' rules out.

All Permutations & Combinations questions · placement mock tests