Skip to content
Glacius
FoundationsConcept reference

Set union

The union of two sets consists of objects that belong to at least one of the sets.

On this page 7 sections
  1. Overview
  2. The union keeps objects that belong to at least one set
  3. If the sets share no members, the union still includes the members from both
  4. Check your understanding
  5. Key takeaway
  6. Sources & further reading
  7. Concept connections

01The union keeps objects that belong to at least one set#

The union keeps objects that belong to at least one set. Here A={2,4,6}A=\{2,4,6\} and B={4,6,8}B=\{4,6,8\}.

A contains 2, 4, 6. B contains 4, 6, 8. Labels 4 and 6 lie in both enclosures. The union includes all four labels once.A contains 2, 4, 6. B contains 4, 6, 8. Labels 4 and 6 lie in both enclosures. The union includes all four labels once.
Figure 1The union is {2,4,6,8}\{2,4,6,8\}.
Link to this figure ↗Download SVGDownload PNG

For A={2,4,6}A=\{2,4,6\} and B={4,6,8}B=\{4,6,8\}, the labels 44 and 66 are shared. The label 22 appears only in AA; 88 appears only in BB.

Collect the qualifying labels.

AB={2,4,6,8}A\cup B=\{2,4,6,8\}

An object needs only one route into the union. Shared labels qualify too, but are written once. Combining the lists does not create a second copy of the same object.

Check your reasoning

A={1,4}A=\{1,4\} and B={4,7}B=\{4,7\}. Build ABA\cup B.

Show answer and explanation

The union is {1,4,7}\{1,4,7\}. Check the stated membership rule for each candidate.

02If the sets share no members, the union still includes the members from both#

If the sets share no members, the union still includes the members from both. If one set is empty, it contributes nothing.

Combine the disjoint sets {1,3}\{1,3\} and {2,4}\{2,4\}.

{1,2,3,4}\{1,2,3,4\}
Check your reasoning

A: {csv, json}; B: {json, xml}. Accept formats in either list, including both. Which set?

  1. A{json}
  2. B{csv, json, xml}
  3. C{csv, xml}
Show answer and explanation
{csv, json, xml}

Keep formats in either list.

03Check your understanding#

Check your reasoning

What is {3,9}\{3,9\}\cup\varnothing?

  1. A{3,9}\{3,9\}
  2. B\varnothing
  3. C{0}\{0\}
Show answer and explanation
{3,9}\{3,9\}

The empty set adds no members; the existing labels remain.

Key takeaway

Check each distinct object against the two sets. Include membership in either or both, without duplicating shared objects.

  • Form the union of two finite sets

Sources & further reading

  1. [1]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Set union.” Math behind ML. /learn/f-union