Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Inclusion-Exclusion and its various Applications

  • Difficulty Level : Easy
  • Last Updated : 17 Aug, 2021

In the field of Combinatorics, it is a counting method used to compute the cardinality of the union set. According to basic Inclusion-Exclusion principle


Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

  • For 2 finite sets A_1  and A_2  , which are subsets of Universal set, then (A_1-A_2), (A_2-A_1)  and (A_1\bigcap A_2)  are disjoint sets. 


  • Hence it can be said that, 
    \left|(A_1-A_2)\bigcup(A_2-A_1)\bigcup(A_1\bigcap A_2)\right| = \left|A_1\right| - \left|A_1\bigcap A_2\right| + \left|A_2\right| - \left|A_1\bigcap A_2\right| + \left|A_1\bigcap A_2\right|

    \left|A_1 \bigcup A_2\right| = \left|A_1\right| + \left|A_2\right| -\left|A_1 \bigcap A_2\right|  .

  • Similarly for 3 finite sets A_1  A_2  and A_3
    \left|A_1 \bigcup A_2 \bigcup A_3\right| = \left|A_1\right| + \left|A_2\right| + \left|A_3\right| - \left|A_1 \bigcap A_2\right| - \left|A_2 \bigcap A_3\right| - \left|A_1 \bigcap A_3\right|+ \left|A_1 \bigcap A_2 \bigcap A_3\right|


Principle :

Inclusion-Exclusion principle says that for any number of finite sets A_1, A_2, A_3... A_i  , Union of the sets is given by = Sum of sizes of all single sets – Sum of all 2-set intersections + Sum of all the 3-set intersections – Sum of all 4-set intersections .. + (-1)^{i+1}  Sum of all the i-set intersections. 

In general it can be said that, 


\left|A_1 \bigcup A_2 \bigcup A_3 .. \bigcup A_i\right| = \sum\limits_{1 \leq k \leq i} \left|A_k\right| + (-1)\sum\limits_{1 \leq k_1 \textless k_2 \leq i} \left|A_{k_1} \bigcap A_{k_2}\right| + (-1)^2\sum\limits_{1 \leq k_1 \textless k_2 \textless k_3 \leq i} \left|A_{k_1} \bigcap A_{k_2} \bigcap A_{k_3}\right| .. + (-1)^{i+1}\sum\limits_{1 \leq k_1 \textless k_2 \textless k_3 \textless .. k_i\leq i} \left|A_{k_1} \bigcap A_{k_2} \bigcap A_{k_3} ..\bigcap A_{k_i}\right|

Properties : 

  1. Computes the total number of elements that satisfy at least one of several properties.
  2. It prevents the problem of double counting.

Example 1: 
As shown in the diagram, 3 finite sets A, B and C with their corresponding values are given. Compute \left|A \bigcup B \bigcup C\right|

Solution : 
The values of the corresponding regions, as can be noted from the diagram are – 
\left|A\right| = 2, \left|B\right| = 2, \left|C\right| = 2, \left|A \bigcap B\right| = 3, \left|B \bigcap C\right| = 3,
\left|A \bigcap C\right| = 3, \left|A \bigcap B \bigcap C\right| = 4

By applying Inclusion-Exclusion principle, 
\left|A_1 \bigcup A_2 \bigcup A_3\right| = \left|A_1\right| + \left|A_2\right| + \left|A_3\right| - \left|A_1 \bigcap A_2\right| - \left|A_2 \bigcap A_3\right| - \left|A_1 \bigcap A_3\right|+ \left|A_1 \bigcap A_2 \bigcap A_3\right|
\left|A_1 \bigcup A_2 \bigcup A_3\right| = 2 + 2 + 2 - 3 - 3 - 3 + 4 = 1


Applications :


  • Derangements 
    To determine the number of derangements( or permutations) of n objects such that no object is in its original position (like Hat-check problem). 
    As an example we can consider the derangements of the number in the following cases: 
    For i = 1, the total number of derangements is 0. 
    For i = 2, the total number of derangements is 1. This is 2 1
    For i = 3, the total number of derangements is 2. These are 2 3 1  and 3 1 2.

My Personal Notes arrow_drop_up
Recommended Articles
Page :