There are 3⁴=81 total functions. Exclude those missing any chosen output using inclusion–exclusion: 3⁴−3×2⁴+3×1⁴=81−48+3=36. The last term restores functions whose image consists of just one output.
More Discrete Mathematics: Combinatorics (Counting, Recurrence Relations, Generating Functions) questions
GATE 2015 CS (CS3) Q25– How many four-digit numbers using only 1,2,3 have digits in nondecreasing order from left…
GATE 2021 CS (CS2) Q60– S has ten elements. How many ordered tuples (A,B) of subsets of S satisfy A⊆B?
GATE 2026 CS (CS1) Q57– Let G be an undirected graph, which is a path on 8 vertices. The number of matchings in G…
GATE 2025 CS (CS1) Q30– Let S be the set of all ternary strings defined over the alphabet \a,b,c\. Consider all…
GATE 2023 CS Q15– The Lucas sequence L n is defined by the recurrence relation: L n = L n-1 + L n-2, for n…
GATE 2023 CS Q48– Let U = \1, 2, , n\, where n is a large positive integer greater than 1000. Let k be a…