![]() |
VOOZH | about |
The Principle of Inclusion and Exclusion (PIE) is a counting technique used to find the size of the union of multiple sets by systematically including and excluding overlapping parts.
👁 inclusionIt corrects the overcounting that happens when you simply add the sizes of the sets. When sets have overlapping elements, counting them directly can lead to overcounting. The Principle of Inclusion and Exclusion fixes this by alternately adding and subtracting the sizes of the intersection to get the exact total.
For example, when calculating the number of people who own a dog or a cat, PIE adds up all dog owners and subtracts all cat owners. This includes:
In general, for n sets A1, A2, . . ., An:
Where:
Note: This formula effectively accounts for all overlaps among the sets, ensuring that each unique element is counted exactly once.
For two sets A and B
∣AUB∣ = ∣A∣+∣B∣-∣A∩B∣
Where,
For three sets A,B, and C, the Principle of Inclusion and Exclusion (PIE) formula to find the size of the union is:
∣AUBUC∣ = ∣A∣+∣B∣+∣C∣-∣A∩B∣-∣A∩C∣-∣B∩C∣+∣A∩B∩C∣
Where,
We can visualize this using a Venn diagram for a finite number of sets. Here we will discuss the formula for the Principle of Inclusion and Exclusion for two and three sets and derive it using a Venn diagram.
Venn Diagram for Two Sets
👁 Venn-Diagram-of-Two-SetsThus, the number of elements in the union of these two sets, ∣A ∪ and B∣, is given by:
∣A∪B∣ = ∣A∣ + ∣B∣ − ∣A∩B∣
Thus, the number of elements in the union of these three sets, ∣A∪B∪C∣, is given by:
∣A∪B∪C∣ = ∣A∣ + ∣B∣ + ∣C∣ − ∣A∩B∣ − ∣B∩C∣ − ∣C∩A∣ + ∣A∩B∩C∣
Principle of Inclusion and Exclusion (PIE) is used quite a lot in Computer Science, especially in areas that deal with counting, probability, and combinatorics.
Here are some key applications:
Question 1: In a class of 100 students:
How many students study either Math or Science?
Solution:
As we know, n(A⋃B) = n(A) + n(B) – n(A⋂B)
Given:
- n(A) = 60
- n(B) = 45
- n(A∩B) = 20
n(A⋃B) = n(A) + n(B) – n(A⋂B) = 60 + 45 - 20 = 85
Thus, 85 students study either Math or Science.
Question 2: The probability of getting at least one head is Problem: In a survey of 120 people:
How many people like either tea or coffee?
Solution:
As we know, n(A⋃B) = n(A) + n(B) – n(A⋂B)
Given:
- IAI = 80
- IBI = 70
- IA∩BI = 50
Thus, n(A⋃B) = 80 + 70 - 50 = 100
Thus, 100 people like either tea or coffee.
Question 3: A company has 30 employees, 10 are assigned to Task A, 15 to Task B, and 5 are assigned to both. How many employees are assigned to at least one task?
Solution:
As we know, n(A⋃B) = n(A) + n(B) – n(A⋂B)
Given:
- IAI = 10 Task A
- IBI = 15 Task B
- IA∩BI = 5 Both tasks
Substitute the Values, We get
n(A⋃B) = 10 + 15 - 5 = 20
Thus, 20 employees are assigned to at least one task.
Question 4: In a survey of 200 people:
How many people like at least one of these three foods?
Solution:
As we know, ∣AUBUC∣ = ∣A∣ + ∣B∣ + ∣C∣ - ∣A∩B∣ - ∣A∩C∣ - ∣B∩C∣ + ∣A∩B∩C∣
Given:
- ∣A∣ = 120 Pizza lovers
- ∣B∣ = 100 Burger lovers
- ∣C∣ = 80 Taco lovers
- ∣A∩B∣ = 60
- ∣A∩C∣ = 30
- ∣B∩C∣ = 40
- ∣A∩B∩C∣ = 20
Substituting in the formula, we get,
∣AUBUC∣ = 120 + 100 + 80 - 60 - 30 - 40 + 20 = 190
Thus, 190 people like at least one of the three foods.
Question 5: In a university of 300 students:
How many students are taking at least one subject?
Solution:
As we know, ∣AUBUC∣ = ∣A∣ + ∣B∣ + ∣C∣ - ∣A∩B∣ - ∣A∩C∣ - ∣B∩C∣ + ∣A∩B∩C∣
Given:
- ∣A∣ = 150 (Math),
- ∣B∣ = 120 (Physics),
- ∣C∣ = 100 (Chemistry),
- ∣A∩B∣ = 80
- ∣A∩C∣ = 60
- ∣B∩C∣ = 50
- ∣A∩B∩C∣ = 30
Substituting values, we get
∣AUBUC∣ = 150 + 120 + 100 - 80 - 60 - 50 + 30 = 210
Thus, 210 students are taking at least one subject.
Question 1: In a group of 200 people:
How many people like either chocolate or vanilla?
Question 2: In a class of 100 students:
How many students play at least one of these three sports?
Question 3: Out of 150 attendees at an event:
How many people attended at least one workshop?
Question 4: A card is drawn from a deck of 52 cards. What is the probability that it is:
There are 13 hearts, 12 face cards, and 26 red cards.
Note that:
Question 5: In a school of 300 students:
How many students are enrolled in at least one subject?
Answer Key
- 160 people like either chocolate or vanilla.
- 120 students play at least one of these sports.
- 110 people attended at least one workshop.
- The probability is 8/13.
- 260 students are enrolled in at least one subject.