CODEBHAVYA • MATHEMATICAL THINKING

⭕ Sets and Venn Diagrams

Learn how collections are represented, compared and combined, and use Venn diagrams to visualize relationships clearly.

🎯 What You Will Learn

01Represent sets using roster and set-builder notation.
02Identify subsets, cardinality and common types of sets.
03Apply union, intersection, difference and complement.
04Read Venn diagrams and solve counting problems.

📦 1. What Is a Set?

A set is a well-defined collection of distinct objects. The objects are called elements or members.

A = {2, 4, 6, 8}
BELONGS TO 4 ∈ A

4 is an element of A.

DOES NOT BELONG TO 5 ∉ A

5 is not an element of A.

CARDINALITY n(A) = 4

A contains four distinct elements.

Important: Repeated entries do not create new elements. The sets {1, 1, 2, 3} and {1, 2, 3} are equal.

✍️ 2. Ways to Represent a Set

ROSTER FORM

List every element

E = {2, 4, 6, 8, 10}

SET-BUILDER FORM

Describe a common rule

E = {x | x is an even natural number and x ≤ 10}

DESCRIPTIVE FORM

Describe in words

E is the set of even natural numbers not exceeding 10.

A collection must be well-defined. “The set of beautiful songs” depends on personal opinion, so membership is not definite.

🗂️ 3. Common Types of Sets

EMPTY SET∅ or { }

Contains no elements.

SINGLETON{7}

Contains exactly one element.

FINITE SET{a, b, c}

Has a countable fixed number of elements.

INFINITE SETN = {1, 2, 3, ...}

Continues without an end.

EQUAL SETSA = B

Contain exactly the same elements.

DISJOINT SETSA ∩ B = ∅

Have no common elements.

UNIVERSAL SETU

Contains every element under discussion.

🧩 4. Subsets and Power Sets

A is a subset of B, written A ⊆ B, when every element of A is also an element of B.

Example If B = {1, 2, 3}, then {1, 3} ⊆ B.

The power set P(A) is the set of all subsets of A. If A has n elements, then P(A) has 2n elements.

If A = {a, b}, then P(A) = {∅, {a}, {b}, {a, b}} and n(P(A)) = 2² = 4.

🔄 5. Set Operations

UNION • A ∪ B

In A or B or both

Combine all distinct elements.

INTERSECTION • A ∩ B

Common to both

Keep only shared elements.

DIFFERENCE • A − B

In A but not B

Remove B’s elements from A.

SYMMETRIC DIFFERENCE • A △ B

In exactly one set

Keep elements that are not shared.

COMPLEMENT • A′

In U but not A

Use the stated universal set.

Operation Example

A = {1, 2, 3, 4} and B = {3, 4, 5, 6}.

Results

A ∪ B = {1, 2, 3, 4, 5, 6}

A ∩ B = {3, 4}

A − B = {1, 2}

A △ B = {1, 2, 5, 6}

⚖️ 6. Important Set Laws

CommutativeA ∪ B = B ∪ A; A ∩ B = B ∩ A
Associative(A ∪ B) ∪ C = A ∪ (B ∪ C)
DistributiveA ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)
IdentityA ∪ ∅ = A; A ∩ U = A
ComplementA ∪ A′ = U; A ∩ A′ = ∅
De Morgan(A ∪ B)′ = A′ ∩ B′; (A ∩ B)′ = A′ ∪ B′

⭕ 7. Reading a Venn Diagram

A Venn diagram places sets inside a rectangle representing U. Overlapping circles show common elements; non-overlapping regions show elements unique to each set.

A ONLYA − B

Inside A and outside B.

OVERLAPA ∩ B

Inside both A and B.

B ONLYB − A

Inside B and outside A.

OUTSIDE BOTH(A ∪ B)′

Inside U but outside both circles.

🧪 Set Operation Explorer

Enter comma-separated elements, choose an operation and observe the highlighted Venn region together with the calculated result.

🧮 8. Counting with Two Sets

n(A ∪ B) = n(A) + n(B) − n(A ∩ B)

The intersection is subtracted once because it was counted in both n(A) and n(B).

CodeBhavya Example

In a class, 28 students know C, 20 know Python and 9 know both. How many know at least one language?

Solution

n(C ∪ P) = 28 + 20 − 9 = 39.

39 students know at least one language.

💻 9. Sets in Programming

REMOVE DUPLICATES

Unique values

Convert repeated input into a collection of distinct elements.

MEMBERSHIP TEST

Fast lookup

Check whether an identifier, permission or item is present.

COMMON DATA

Intersection

Find users, skills or records shared by two groups.

MERGE DATA

Union

Combine two groups without repeating elements.

📘 10. Solved Problems

Problem 1

A = {2, 4, 6, 8}, B = {4, 8, 12}. Find A ∩ B.

Solution

The elements appearing in both sets are 4 and 8.

A ∩ B = {4, 8}

Problem 2

U = {1, 2, 3, 4, 5, 6}, A = {2, 4, 6}. Find A′.

Solution

Keep the elements of U that do not belong to A.

A′ = {1, 3, 5}

Problem 3

If n(A) = 24, n(B) = 19 and n(A ∩ B) = 7, find n(A ∪ B).

Solution

n(A ∪ B) = 24 + 19 − 7 = 36.

n(A ∪ B) = 36

✍️ 11. Practice Problems

Solve each question first, then open the solution to verify your set operation.

1. Write the set of vowels in English using roster form.

2. If A = {1, 2, 3} and B = {3, 4, 5}, find A ∪ B.

3. Find the number of subsets of {p, q, r}.

4. U = {1, 2, 3, 4, 5}, A = {1, 3, 5}. Find A′.

5. In a group, 32 like tea, 25 like coffee and 12 like both. How many like at least one?

📝 Quick Revision

  • A set is a well-defined collection of distinct elements.
  • Roster form lists elements; set-builder form describes a rule.
  • A ⊆ B means every element of A belongs to B.
  • An n-element set has 2n subsets.
  • Union combines, while intersection keeps common elements.
  • A − B keeps elements in A but not B.
  • A′ contains elements of U that are outside A.
  • Use n(A ∪ B) = n(A) + n(B) − n(A ∩ B).
  • Venn diagrams make regions and overlaps visible.

⭕ Sets and Venn Diagrams Practice

Answer all 20 questions, submit once, and then review your score, correct answers and complete explanations.

Start 20-Question Test →