GATE / CS ARCHIVE

SIMILAR QUESTIONS / DISCRETE MATHEMATICS

Count assignments while excluding empty required destinations

3 questions solved the same way, newest first. Back to Discrete Mathematics

How these are solved

Both count functions assigning distinct objects to distinct labels with required nonempty images: start with all assignments and subtract cases missing required labels, using inclusion-exclusion. In 2015 all three codomain labels must occur among four arguments.

1 mark · NAT
Report issue

Combinatorics & Counting

Question 19, GATE 2021: Assign six distinct jobs of distinct difficulty to three distinct computers of distinct speeds. The fastest must get the toughest job, the slowest the easiest, and each computer must receive at least one job. How many assignments are possible?
Tap to enlarge
Answer & solution

Official answer: 65

Fix the toughest job on the fastest computer and the easiest on the slowest. Each of the four remaining distinct jobs has 3 destination choices, giving 3⁴. Subtract assignments that leave the middle-speed computer empty: all four then go to the other two computers, giving 2⁴. Thus3⁴−2⁴=81−16=65.

The extreme jobs are fixed, leaving four labeled jobs, not four indistinguishable units. The fastest and slowest computers are already nonempty, so only the middle computer requires an inclusion-exclusion correction. For a second count, assign exactly k of the four remaining jobs to the middle computer: Σ_(k=1)4 binom(4,k)24−k=32+24+8+1=65.

Original paper, page 20 · Answer key

2 marks · NAT
Report issue

Asked again GATE 2012, Q37 (different numbers)

Sets, Relations & Functions

Question 58, GATE 2015: How many onto functions exist from a four-element set to a three-element set?
Tap to enlarge
Answer & solution

Official answer: 36

There are 34 total functions. Exclude functions omitting at least one codomain value by inclusion-exclusion: 34−C(3, 1)24+C(3, 2)14=81−48+3=36. Equivalently choose the repeated pair of domain elements in 6 ways, its image in 3 ways and assign the other two images in 2 ways.

There are 3⁴=81 functions in total. For each of the three codomain elements, 2⁴=16 functions omit it. Subtract 3·16, then restore the three intersections where only one codomain element is used. The result is 81−48+3=36. Equivalently, an onto function must have fiber sizes 2, 1, 1: choose the repeated pair in C(4, 2)=6 ways, its image in 3 ways and assign the remaining two images in 2 ways. Both counts give 36.

Original paper, page 48 · Answer key

2 marks · MCQ
Report issue

Asked again GATE 2015 Set 2, Q58 (different numbers)

Surjections to a two-element codomain

Sets, Relations & Functions

Question 37, GATE 2012: How many onto (surjective) functions exist from an n-element set, n≥2, to a two-element set?
(A) 2^n (B) 2^n−1 (C) 2^n−2 (D) 2(2^n−2).
Tap to enlarge
Your answer
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.

Original paper, page 10 · Answer key