Question

The number of 4 digit numbers having their digits in non-decreasing order (from left to right) constructed by using the digits belonging to the set {1,2,3}\{1, 2, 3\} is _____.

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

Solution

Map non-decreasing digit sequences to combinations with repetition (multisets).

We need to form 4-digit numbers d1d2d3d4d_1 d_2 d_3 d_4 where each di∈{1,2,3}d_i \in \{1, 2, 3\} and d1≤d2≤d3≤d4d_1 \le d_2 \le d_3 \le d_4.

Because the digits must be in non-decreasing order from left to right, once any multiset of 4 digits is chosen from {1,2,3}\{1, 2, 3\}, there is exactly one way to arrange them in non-decreasing order.

Thus, the number of such 4-digit numbers equals the number of ways to choose 4 elements from a set of 3 distinct elements with replacement (combinations with repetition).

Using the stars and bars formula (n+r−1r)\binom{n + r - 1}{r} with n=3n = 3 and r=4r = 4:

(3+4−14)=(64)=(62)=6×52×1=15\binom{3 + 4 - 1}{4} = \binom{6}{4} = \binom{6}{2} = \frac{6 \times 5}{2 \times 1} = 15

Direct enumeration verifies the result:

  • All digits identical: 1111,2222,33331111, 2222, 3333 (3 numbers)
  • Three of one digit, one of another: 1112,1113,1222,2223,1333,23331112, 1113, 1222, 2223, 1333, 2333 (6 numbers)
  • Two of one digit, two of another: 1122,1133,22331122, 1133, 2233 (3 numbers)
  • Two of one digit, one each of other two: 1123,1223,12331123, 1223, 1233 (3 numbers)
    Total =3+6+3+3=15= 3 + 6 + 3 + 3 = 15.
Final answer

15

Common trap

Using permutations instead of combinations, forgetting that the non-decreasing ordering constraint fixes the sequence uniquely.

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 3
Question
15 of 65, printed as CS Q.5
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.