Onto (Surjective) Function MCQs: 11 Solved Questions on Definition, Count and Properties

Solve six MCQs, one MSQ and four NAT questions on onto functions. Each answer explains the exact definition, proof or counting step you need.

KnowledgeGate Team

Exam prep & CS education

Updated 4 Sep 20268 min read

Recognising an onto mapping is easy in a clean arrow diagram. Exam questions hide the same idea inside composition, inclusion-exclusion, job assignment, involutions and quotient sets. The set contains six MCQs, one MSQ and four NAT questions. Before viewing an answer, write the range or identify the missing-codomain cases yourself on paper. Use GATE CS Exam Preparation for the broader GATE CS preparation sequence.

Onto functions: range, composition and counting in one refresher

For a function f: A -> B, the set A is the domain and B is the codomain. The Function MCQs: 11 Solved on Domain, Range & Counting provides the broader foundation. Surjectivity narrows the test: every b in B has at least one preimage a in A. Equivalently, Range(f) = B.

Let A={1,2,3,4} and B={a,b,c}. If f(1)=a, f(2)=b, f(3)=c and f(4)=c, the range is {a,b,c}, so f is onto. It is not one-to-one because 3 and 4 collide at c. An onto function may have such collisions, but it cannot leave a codomain element unused. By contrast, if p(1)=a, p(2)=b, p(3)=b and p(4)=a, then Range(p)={a,b}. The element c has no preimage, so p is not onto.

For domain size m and codomain size n, the number of onto functions is 0 when m<n. Otherwise, inclusion-exclusion gives sum from i=0 to n of (-1)^i C(n,i)(n-i)^m. It corrects for missed codomain values. For a two-element codomain, the shortcut is 2^m-2, because only the two constant functions fail to be onto.

Two arrow diagrams from {1,2,3,4} to {a,b,c}: the onto map reaches all of a, b and c, while the not-onto map leaves c with no preimage.

Questions 1-2: definition and composition

Question 1

A function is considered surjective or onto when:

  • A. Each element in the domain maps to a unique element in the codomain

  • B. Some elements in the domain map to the same element in the codomain

  • C. Every element in the codomain has a pre-image in the domain

  • D. No two elements in the domain map to the same element in the codomain

Correct answer: C. Every element in the codomain has a pre-image in the domain.

Take A={1,2,3,4}, B={a,b,c}, with f(1)=a, f(2)=b, f(3)=c, f(4)=c. Every codomain value has a preimage, so f is onto. A and D describe injectivity. B may occur, as the collision at c shows, but a collision alone does not prove onto.

Question 2 (GATE CS 2005)

Let f: B → C and g: A → B be two functions and let h = f ∘ g. Given that h is an onto function. Which one of the following is TRUE?

  • A. f and g should both be onto functions

  • B. f should be onto but g need not be onto

  • C. g should be onto but f need not be onto

  • D. both f and g need not be onto

Correct answer: B. f should be onto but g need not be onto.

In h=f∘g, g acts first and f second. Onto h makes each c equal f(g(a)), so f is onto. Let A={1,2}, B={u,v,w}, C={0,1}, with g(1)=u, g(2)=v; g misses w. Set f(u)=0, f(v)=1, f(w)=0; then f and h are onto. Thus B is correct. Solved page.

Questions 3-5: count onto functions with inclusion-exclusion

For three codomain values, subtract functions missing one output and restore overlaps missing two. Permutations and Combinations for GATE CS: One Method explains this inclusion-exclusion assignment logic.

Question 3 (GATE CS Set 2, 2015)

The number of onto functions (surjective functions) from set 𝑋 = {1, 2, 3, 4} to set 𝑌 = {𝑎, 𝑏, 𝑐} is __________.

Options: None; this is a numerical-answer question.

Correct answer: 36.

Start with 3^4=81. Subtract C(3,1)2^4=3*16=48 functions missing one output, then restore C(3,2)1^4=3: 81-48+3=36. Check constructively: choose the paired inputs in C(4,2)=6 ways, then assign the three nonempty blocks to a,b,c in 3!=6 ways, giving 6*6=36. Solved page.

Question 4 (GATE CS 2012)

How many onto (or surjective) functions are there from an n-element (n ≥ 2) set to a 2-element set?

  • A. 2^n

  • B. 2^n - 1

  • C. 2^n - 2

  • D. 2(2^n - 2)

Correct answer: C. 2^n - 2.

There are 2^n functions. Only the two constant functions miss an output, so the answer is 2^n-2. For n=3, remove 000 and 111 from 000,001,010,011,100,101,110,111, leaving six. Solved page.

Question 5

The total number of onto functions possible if f: A→B and |A| = 5 and |B| = 3 is :

Options: None; this is a numerical-answer question.

Correct answer: 150.

Compute 3^5-C(3,1)2^5+C(3,2)1^5 = 243-3*32+3 = 150. The +3 restores the three one-output functions in the overlaps. Only the domain exponent changed from Question 3.

Questions 6-7: composition claims and involutions

Question 6

Let f:A→B and g:B→C denotes two function. Consider the following which one are valid S1: If both f and g are injection then the composition function g o f : A→C is also injection. S2: if g o f :A→C is surjection then g is surjection and f is injection.

  • A. S1

  • B. S2

  • C. S1 and S2

  • D. none

Correct answer: A. S1.

For S1, g(f(x1))=g(f(x2)) gives f(x1)=f(x2), then x1=x2, by injectivity of g, then f. For S2, set A={1,2,3}, B={u,v,w}, C={0,1}, with f(1)=u, f(2)=u, f(3)=v, and g(u)=0, g(v)=1, g(w)=1. Then g∘f and g are onto, but f is not. S2 is false.

Question 7 (GATE CS Set 3, 2014)

Consider the set of all functions f: {0, 1, …, 2014} → {0, 1, …, 2014} such that f(f(i)) = i, for all 0 ≤ i ≤ 2014. Consider the following statements: P. For each such function it must be the case that for every i, f(i) = i. Q. For each such function it must be the case that for some i, f(i) = i. R. Each function must be onto. Which one of the following is CORRECT?

  • A. P, Q and R are true

  • B. Only Q and R are true

  • C. Only P and Q are true

  • D. Only R is true

Correct answer: B. Only Q and R are true.

The 2015 elements form fixed points or 2-cycles. P is false: swap 0 and 1, then fix the rest. Q is true because an odd-sized set cannot consist only of pairs. R is true because each i has preimage f(i). Solved page.

Questions 8-9: translate assignments and cardinalities into surjections

Question 8 (UGC NET CS 2021)

How many ways are there to assign 5 different jobs to 4 different employees if every employee is assigned at least 1 job?

  • A. 1024

  • B. 625

  • C. 240

  • D. 20

Correct answer: C. 240.

Map each job to its employee. Onto means every employee gets a job. Choose the employee receiving two jobs in 4 ways, those jobs in C(5,2)=10 ways, and match the rest in 3!=6 ways. Thus 4*10*6=240; 4^5=1024 is unrestricted. Solved page.

Question 9 (GATE CS Set 1, 2024)

Let 𝐴 and 𝐵 be non-empty finite sets such that there exist one-to-one and onto functions (i) from 𝐴 to 𝐵 and (ii) from 𝐴 × 𝐴 to 𝐴 ∪ 𝐵. The number of possible values of |𝐴| is __________

Options: None; this is a numerical-answer question.

Correct answer: 2.

The first bijection gives |A|=|B|=n>=1; the second gives n^2=|A union B|. Since n <= |A union B| <= 2n, require n <= n^2 <= 2n, leaving n=1,2. Both work: take A=B={0}, or disjoint A={1,2}, B={3,4}. Hence |A| has two values. Solved page.

Questions 10-11: quotient classes and the pigeonhole test

Question 10 (GATE CS 2023)

Let f : A → B be an onto (or surjective) function, where A and B are nonempty sets. Define an equivalence relation ∼ on the set A as a1 ∼ a2 if f(a1) = f(a2), where a1, a2 ∈ A. Let ε = {[x] : x ∈ A} be the set of all the equivalence classes under ∼. Define a new mapping F : ε → B as F([x]) = f(x), for all the equivalence classes [x] in ε. Which of the following statements is/are TRUE?

  • A. F is NOT well-defined.

  • B. F is an onto (or surjective) function.

  • C. F is a one-to-one (or injective) function.

  • D. F is a bijective function.

Correct answers: B, C and D.

Let A={1,2,3,4}, B={a,b}, with fibers {1,2}->a and {3,4}->b; these are the classes. F is well-defined because class members share an f-value. It is onto because f is onto, and injective because equal values identify one class. Hence it is bijective, so B, C and D hold. Solved page.

Question 11

Consider two sets A and B with ∣A∣=4 and ∣B∣=3. The number of onto functions f from A to B which satisfy the property x1=x2 iff f(x1)=f(x2) is,______

Options: None; this is a numerical-answer question.

Correct answer: 0.

The reverse implication f(x1)=f(x2) => x1=x2 demands injectivity; the forward implication is automatic. Four inputs cannot map injectively to three outputs by the pigeonhole principle. Adding onto cannot rescue this, so the count is zero.

Score map, common traps and the next practice step

Use these as revision bands.

Score

Revision action

9-11 correct

Revise only the missed theorem or count.

6-8 correct

Redo the arrow diagram and both inclusion-exclusion examples, then retake.

0-5 correct

Rebuild domain, codomain, range, injective and surjective definitions.

Five traps:

  • Check codomain coverage, not domain usage.

  • Repeated images are allowed when the whole codomain is reached.

  • Use 2^n-2 only for a two-element codomain.

  • For onto composition, the outer component must be onto.

  • “Every employee gets a job” means surjection.

Use Engineering Mathematics for GATE Exam for a structured mathematics sequence. Retake the set without explanations, writing the range, missed outputs or function model first.