Question

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 _____.

Official answer and solution
Official answer
36
From
Official GATE 2015 answer key

Solution

Apply the Principle of Inclusion-Exclusion to count surjective functions from a 4-element set to a 3-element set.

We need the number of onto functions from set XX (∣X∣=4|X| = 4) to set YY (∣Y∣=3|Y| = 3).

By the Principle of Inclusion-Exclusion, the number of onto functions is given by:

∑k=0n(−1)k(nk)(n−k)m\sum_{k=0}^{n} (-1)^k \binom{n}{k} (n - k)^m

where m=4m = 4 and n=3n = 3.

Calculating each term:

  • k=0k = 0: (30)34=1×81=81\binom{3}{0} 3^4 = 1 \times 81 = 81
  • k=1k = 1: −(31)24=−3×16=−48-\binom{3}{1} 2^4 = -3 \times 16 = -48
  • k=2k = 2: +(32)14=+3×1=+3+\binom{3}{2} 1^4 = +3 \times 1 = +3
  • k=3k = 3: −(33)04=0-\binom{3}{3} 0^4 = 0

Total number of onto functions:

81−48+3=36.81 - 48 + 3 = 36.

Alternatively, partitioning 4 distinct elements into 3 non-empty subsets must be of sizes 2+1+12 + 1 + 1. The number of ways to partition is (42)=6\binom{4}{2} = 6, and the number of ways to assign the 3 subsets to the 3 target elements is 3!=63! = 6. Total onto functions = 6×6=366 \times 6 = 36.

Final answer

36

Common trap

Computing total functions 34=813^4 = 81 without subtracting non-surjective functions.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2015 Computer Science and Information Technology (CS) Session 2
Question
50 of 65, printed as CS Q.40
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.