Skip to content
Official PYQ · 2015

GATE CS 2015 Set 2 Q40 — Sets, Relations and Functions

Explain with AI
The number of onto functions (surjective functions) from set X={1,2,3,4}X = \{1, 2, 3, 4\} to set Y={a,b,c}Y=\{a,b,c\} is ______.
View worked solution

Answer: 36

We need to find the number of onto (surjective) functions from a set XX of size n=4n = 4 to a set YY of size m=3m = 3.

We can solve this using two standard methods:

Method 1: Principle of Inclusion-Exclusion (PIE)

The total number of onto functions from a set of size nn to a set of size mm is given by the formula:

Number of onto functions=∑k=0m(−1)k(mk)(m−k)n\text{Number of onto functions} = \sum_{k=0}^{m} (-1)^k \binom{m}{k} (m-k)^n

Substituting n=4n = 4 and m=3m = 3:

Number of onto functions=34−(31)(3−1)4+(32)(3−2)4=81−3(24)+3(14)=81−3(16)+3(1)=81−48+3=36\begin{aligned} \text{Number of onto functions} &= 3^4 - \binom{3}{1}(3-1)^4 + \binom{3}{2}(3-2)^4 \\ &= 81 - 3(2^4) + 3(1^4) \\ &= 81 - 3(16) + 3(1) \\ &= 81 - 48 + 3 \\ &= 36 \end{aligned}

Method 2: Partitioning (Stirling Numbers of the Second Kind)

An onto function maps 44 elements of XX to 33 elements of YY such that no element in YY is left empty. This is equivalent to partitioning the 44 elements of XX into 33 non-empty subsets, and then assigning each subset to a unique element in YY.

  1. The only way to partition 44 elements into 33 non-empty groups is of the size distribution {2,1,1}\{2, 1, 1\}.
  2. The number of ways to partition 44 distinct elements into 33 unlabeled groups of sizes 2,1,12, 1, 1 is given by the Stirling number of the second kind, S(4,3)S(4, 3): S(4,3)=4!2!⋅1!⋅1!⋅2!=6S(4, 3) = \frac{4!}{2! \cdot 1! \cdot 1! \cdot 2!} = 6
  3. Since the target set YY has labeled elements, we can assign these 33 groups to the 33 elements of YY in 3!3! ways: Total onto functions=S(4,3)×3!=6×6=36\text{Total onto functions} = S(4, 3) \times 3! = 6 \times 6 = 36

Thus, the number of onto functions is 36.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Sets, Relations and Functions questions