Similar questions 2 more → · asked again: GATE 2015 Set 2, Q58
Sets, Relations & Functions

Answer & solution
Official answer: C
Each of n domain elements has two choices, giving 2n functions. A function is not onto precisely when all n elements map to one fixed codomain element. There are two such constant functions. Subtract them to obtain 2n−2 surjections, C.
Check: For n=2 the four functions are the two constants and the two bijections, leaving two onto functions. The formula 2²−2=2 passes this small-case check and explains why subtracting just one constant function is insufficient.