250+ TOP MCQs on Functions and Answers

Discrete Mathematics Multiple Choice Questions on “Functions”.

1. A function is said to be ______________ if and only if f(a) = f(b) implies that a = b for all a and b in the domain of f.
a) One-to-many
b) One-to-one
c) Many-to-many
d) Many-to-one

Answer: b
Clarification: A function is one-to-one if and only if f(a)≠f(b) whenever a≠b.

2. The function f(x)=x+1 from the set of integers to itself is onto. Is it True or False?
a) True
b) False

Answer: a
Clarification: For every integer “y” there is an integer “x ” such that f(x) = y.

3. The value of ⌊1/2.⌊5/2⌋ ⌋ is ______________
a) 1
b) 2
c) 3
d) 0.5

Answer: a
Clarification: The value of ⌊5/2⌋ is 2 so, the value of ⌊1/2.2⌋ is 1.

4. Which of the following function f: Z X Z → Z is not onto?
a) f(a, b) = a + b
b) f(a, b) = a
c) f(a, b) = |b|
d) f(a, b) = a – b

Answer: c
Clarification: The function is not onto as f(a)≠b.

5. The domain of the function that assign to each pair of integers the maximum of these two integers is ___________
a) N
b) Z
c) Z +
d) Z+ X Z+

Answer: d
Clarification: The domain of the integers is Z+ X Z+.

6. Let f and g be the function from the set of integers to itself, defined by f(x) = 2x + 1 and g(x) = 3x + 4. Then the composition of f and g is ____________
a) 6x + 9
b) 6x + 7
c) 6x + 6
d) 6x + 8

Answer: a
Clarification: The composition of f and g is given by f(g(x)) which is equal to 2(3x + 4) + 1.

7. __________ bytes are required to encode 2000 bits of data.
a) 1
b) 2
c) 3
d) 8

Answer: b
Clarification: Two bytes are required to encode 2000 (actually with 2 bytes you can encode up to and including 65,535.

8. The inverse of function f(x) = x3 + 2 is ____________
a) f -1 (y) = (y – 2) 1/2
b) f -1 (y) = (y – 2) 1/3
c) f -1 (y) = (y) 1/3
d) f -1 (y) = (y – 2)

Answer: b
Clarification: To find the inverse of the function equate f(x) then find the value of x in terms of y such that f -1 (y) = x.

9. The function f(x) = x3 is bijection from R to R. Is it True or False?
a) True
b) False

Answer: a
Clarification: The function f(x) = x3 is one to one as no two values in domain are assigned the same value of the function and it is onto as all R of the co domain is images of elements in the domain.

10. The g -1({0}) for the function g(x)= ⌊x⌋ is ___________
a) {x | 0 ≤ x < 1}
b) {x | 0 < x ≤ 1}
c) {x | 0 < x < 1}
d) {x | 0 ≤ x ≤ 1}

Answer: d
Clarification: g({0}) for the function g(x) is {x | 0 ≤ x ≤ 1}. Put g(x) = y and find the value of x in terms of y such that ⌊x⌋ = y.

250+ TOP MCQs on Inverse of Matrices and Answers

Discrete Mathematics Multiple Choice Questions on “Inverse of Matrices”.

1. For a matrix A, B and identity matrix I, if a matrix AB=I=BA then?
a) B is inverse of A
b) A is inverse of B
c) A-1 = B, B-1 = A
d) All of the mentioned

Answer: d
Clarification: Since AB = I, A = B-1 Similarly A is the inverse of B.

2. For matrix A,(A3) = I, A-1 is equals to _________
a) A2
b) A-2
c) Can’t say
d) None of the mentioned

Answer: a
Clarification: A(A2) = I this implies A-1 = A2.

3. Let A = [0 1 0 0 ], A-1 is equal to _________
a) Null matrix
b) Identity matrix
c) Does not exist
d) None of the mentioned

Answer: c
Clarification: Since A is singular matrix, inverse does not exists.

4. If A is an invertible square matrix then _________
a) (AT)-1 = (A-1)T
b) (AT)T = (A-1)T
c) (AT)-1 = (A-1)-1
d) None of the mentioned

Answer: a
Clarification: For invertible matrix A, AT is also inveritble.

5. If matrix A, B and C are invertible matrix of same order then (ABC)-1 = _________
a) CBA
b) C-1 B-1 A-1
c) CT B-1 AT
d) None of the mentioned

Answer: b
Clarification: Reversal rule holds for inverse multiplication of the matrices.

6. If A is non singular matrix then AB = AC implies B = C.
a) True
b) False

Answer: a
Clarification: Pre-multipliying by A-1 we get B = C.

7. For a matrix A of order n, the det(adj(A)) = (det(A))n, where adj() is adjoint of matrix.
a) True
b) False

Answer: b
Clarification: For a matrix A of order n, the det(adj(A)) = (det(A))n-1.

8. For a non-singular matrix A, A-1 is equal to _________
a) (adj(A))/det(A)
b) det(A)*(adj(A))
c) det(A)*A
d) none of the mentioned

Answer: a
Clarification: A(adj(A)) = det(A)I, I = A(adj(A))/det(A) which implies A-1 = (adj(A))/det(A).

9. Let I3 be the Identity matrix of order 3 then (I3)-1 is equal to _________
a) 0
b) 3I3
c) I3
d) None of the mentioned

Answer: c
Clarification: Idenity matrices are self invertible that is I3 x I3 = I3.

10. If for a square matrix A(non-singular) and B, null matrix O, AB = O then?
a) B is a null matrix
b) B is a non singular matrix
c) B is a identity matrix
d) All of the mentioned

Answer: a
Clarification: Given det(A) is not equal to zero. A-1 exists, A-1(AB) = O, B = O.

250+ TOP MCQs on Number Theory – Primes and Greatest Common Divisors

Discrete Mathematics Multiple Choice Questions on “Number Theory – Primes and Greatest Common Divisors”.

1. The prime factorization of 7007 is __________
a) 73.11.13
b) 72.11.13
c) 7.11.13
d) 7.113.13

Answer: b
Clarification: Perform successive division beginning with 2.

2. Out of following which one is Mersenne Primes?
a) 3
b) 7
c) 2047
d) 31

Answer: c
Clarification: 2047 = 23.89 also not in form of 2b-1 form.

3. Out of the following which of these integers is not prime?
a) 21
b) 35
c) 71
d) 101

Answer: b
Clarification: 35 = 5.7 which is the product of two prime numbers.

4. The prime factorization of 1001 is __________
a) 73.11.13
b) 72.11.13
c) 7.11.13
d) 7.113.13

Answer: c
Clarification: Perform successive division beginning with 2.

5. Which positive integer less than 21 are relatively prime to 21?
a) 18
b) 19
c) 21
d) 24

Answer: b
Clarification: gcd(19,21) = 1. According to the definition of relatively prime gcd of two numbers is 1.

6. Is 7, 8, 9, 11 are pairwise relatively prime.
a) True
b) False

Answer: a
Clarification: gcd(7, 9) = gcd(8, 9) = gcd(9, 11) = gcd(11, 7) = 1. The numbers 7 and 11 are prime and numbers 8 and 9 are relatively prime.

7. The greatest common divisor of 313.517 and 212.35 is __________
a) 30
b) 31
c) 33
d) 35

Answer: d
Clarification: gcd(a, b) = 3min(13, 5).5min(17, 0).2min(12, 0).

8. The greatest common divisor of 0 and 5 is ___________
a) 0
b) 1
c) 2
d) 5

Answer: b
Clarification: gcd(0, 5) = 0min(1, 0).5min(0, 1).

9. The lcm of 3 and 21 is ________ if gcd(3,21)=3.
a) 3
b) 12
c) 21
d) 42

Answer: c
Clarification: 3 * lcm(3, 21) = 63 hence, lcm(3, 21) = 63 / 3 = 21.

10. The least common multiple of 41.42 and 42.41 is ____________
a) 42
b) 41
c) 84
d) 41.42

Answer: d
Clarification: lcm(41 * 42, 42 * 42) = 41.42.42.41 / 41.42 = 41.42.

250+ TOP MCQs on Counting – Derangements and Answers

Discrete Mathematics Multiple Choice Questions on “Counting – Derangements”.

1. Determine the number of derangements of (2, 4, 6, 1, 3, 5) that end with integer 2, 4 and 6 in some order?
a) 128
b) 29
c) 54
d) 36

Answer: d
Clarification: The place of 2, 4, 6 is specified i.e. each of them will get their place out of the last 3 places only. So 1, 3, 5 will automatically get one of the places in the first 3 places. This must ensure that 2, 4 and 6 occupies one of the last 3 places each and 1, 3 and 5 one of 1st 3 places each. Hence, 1, 3 and 5 can be arranged in 3! ways and 2, 4 and 6 also in 3! Ways. So, no of such derangements = 3! * 3! = 6 * 6 = 36.

2. A nursery teacher has 5 pencil boxes to give out to her five students. Determine the probability that at least one student gets their name tag?
a) (frac{19}{30})
b) (frac{26}{47})
c) (frac{123}{537})
d) (frac{12}{79})

Answer: a
Clarification: There are 5!= 120 ways to give out the pencil boxes. By using complementary probability, the number of ways where nobody gets their pencil boxes is
5!((frac{1}{0!} – frac{1}{1!} + … – frac{1}{5!}))
= 44. Hence, the required probability is (frac{120 – 44}{120} = frac{19}{30}).

3. Farhan has received 9 gifts from 9 different people. In how many ways can Farhan receives the gifts such that no one gives him real gifts?
a) 133496
b) 326654
c) 218744
d) 745331

Answer: a
Clarification: By the derangements formula, the number of possible derangements should be 9!((frac{1}{0!} – frac{1}{1!} + … – frac{1}{9!})) = 133496. Hence, there are a total of ways to give the gifts to him such that no one distributes the real gifts.

4. There are 7 groups in a picnic who has brought their own lunch box, and then the 7 lunch box are exchanged within those groups. Determine the number of ways that they can exchange the lunch box such that none of them can get their own.
a) 655
b) 328
c) 1854
d) 3765

Answer: c
Clarification: This can be solved by the derangement formula:
!n = n!(1 – (frac{1}{1!} + frac{1}{2!} – frac{1}{3!} + … + frac{(-1)^n1}{n!})) ⇒ 7! = 1854.

5. Computational complexity of derangements is of __________
a) NP-complete
b) NP-hard
c) NP
d) P

Answer: a
Clarification: Computational complexity of derangements is NP-complete in order to determine whether a given permutation group consists of any derangements or not.

6. There are 5 different-colored boxes in a room each with a distinct cover. Find out the number of ways so that these covers can be put on the boxes such that none of the boxes can have right covers on it? (Assume that all the covers must be on the boxes).
a) 208
b) 137
c) 239
d) 24

Answer: d
Clarification: Let the box covers be A, B, C, D and E. The possible ways for the covers to not be in the exact order of A, B, C, D, E are: 4! = 24 ways. (Since correct order i.e., A, B, C, D and E must be eliminated from such arrangements).

7. A postman can put 12 letters into their respective envelopes such that exactly 5 will go into the right envelope. Find the number of ways of doing this work.
a) 2984300
b) 1610496
c) 5322167
d) 3768650

Answer: b
Clarification: The number of ways in which the 5 correct envelopes can be selected = 12C5 = 864
Derangement of the remaining 7 envelopes & letters = 1864 (derangement value for 7 is 1864)
Total No of ways of arrangement = 1864 * 864 = 1610496.

8. Determine the number of ways In a single competition a singing couple from 5 boys and 5 girls can be formed so that no girl can sing a song with their respective boy?
a) 123
b) 44
c) 320
d) 21

Answer: b
Clarification: This is a case of derangement of 5 boys and 5 girls. The required number of ways can be described as D = 5! (1 – (frac{1}{1!} + frac{1}{2!} – frac{1}{3!} + frac{1}{4!} – frac{1}{5!}) = 120(frac{11}{30})) = 44 ways.

9. What is the sum of all 6 digit numbers which can be formed using the digits 2, 3, 5, 6 and 9 exactly once?
a) 986546600
b) 25611866
c) 433338798
d) 319999680

Answer: d
Clarification: Note that sum of all possible numbers = (n-1)!(sum of the digits involved)(1111…n times), where n is the number of digits. Here n = 6, we have (6-1)!(2+3+5+6+9)(111111) = 5!*(24)*(111111) = 319999680.

10. Determine the average of all four digit numbers that can be made using all the digits 2, 3, 5, 7 and 11 exactly once?
a) 3993
b) 1555
c) 5486
d) 1347

Answer: b
Clarification: First we need to find the sum of all possible numbers and then divide it by the total such numbers possible to gain an average of all the numbers. So, we have (n-1)!(sum of digits)(1111…n times)/n!. Here n = 4. Therefore, (5-1)!(2+3+5+7+11)(1111)/5! = 1555.

250+ TOP MCQs on Types of Relations and Answers

Discrete Mathematics Multiple Choice Questions on “Types of Relations”.

1. The binary relation {(1,1), (2,1), (2,2), (2,3), (2,4), (3,1), (3,2)} on the set {1, 2, 3} is __________
a) reflective, symmetric and transitive
b) irreflexive, symmetric and transitive
c) neither reflective, nor irreflexive but transitive
d) irreflexive and antisymmetric

Answer: c
Clarification: Not reflexive -> (3,3) not present; not irreflexive -> (1, 1) is present; not symmetric -> (2, 1) is present but not (1, 2); not antisymmetric – (2, 3) and (3, 2) are present; not asymmetric -> asymmetry requires both antisymmetry and irreflexivity. So, it is transitive closure of relation.

2. Consider the relation: R’ (x, y) if and only if x, y>0 over the set of non-zero rational numbers,then R’ is _________
a) not equivalence relation
b) an equivalence relation
c) transitive and asymmetry relation
d) reflexive and antisymmetric relation

Answer: b
Clarification: Reflexive: a, a>0
Symmetric: if a, b>0 then both must be +ve or -ve, which means b, a > 0 also exists
Transitive: if a, b>0 and b, c>0 then to have b as same number, both pairs must be +ve or -ve which implies a, c>0. Hence, R’ is an equivalence relation.

3. Let S be a set of n>0 elements. Let be the number Br of binary relations on S and let Bf be the number of functions from S to S. The expression for Br and Bf, in terms of n should be ____________
a) n2 and 2(n+1)2
b) n3 and n(n+1)
c) n and n(n+6)
d) 2(n*n) and nn

Answer: d
Clarification: For a set with n elements the number of binary relations should be 2(n*n) and the number of functions should be nn. Hence Br = 2(n*n) and Bf = nn.

4. Let A be a set of k (k>0) elements. Which is larger between the number of binary relations (say, Nr) on A and the number of functions (say, Nf) from A to A?
a) number of relations
b) number of functions
c) the element set
d) number of subsets of the relation

Answer: a
Clarification: For a set with k elements the number of binary relations should be 2(n*n) and the number of functions should be nn. Now, 2(n*n) => n2log (2) [taking log] and nn => nlog (n) [taking log]. It is known that n2log (2) > nlog (n). Hence, the number of binary relations > the number of functions i.e, Nr > Nf.

5. Consider the binary relation, A = {(a,b) | b = a – 1 and a, b belong to {1, 2, 3}}. The reflexive transitive closure of A is?
a) {(a,b) | a >= b and a, b belong to {1, 2, 3}}
b) {(a,b) | a > b and a, b belong to {1, 2, 3}}
c) {(a,b) | a <= b and a, b belong to {1, 2, 3}}
d) {(a,b) | a = b and a, b belong to {1, 2, 3}}

Answer: a
Clarification: By definition of Transitive closure we have that a is related to all smaller b (as every a is related to b – 1) and from the reflexive property a is related to a.

6. Let R1 be a relation from A = {1, 3, 5, 7} to B = {2, 4, 6, 8} and R2 be another relation from B to C = {1, 2, 3, 4} as defined below:
i. An element a in A is related to an element b in B (under R1) if a * b is divisible by 3.
ii. An element a in B is related to an element b in C (under R2) if a * b is even but not divisible by 3. Which is the composite relation R1R2 from A to C?
a) R1R2 = {(1, 2), (1, 4), (3, 3), (5, 4), (5,6), (7, 3)}
b) Φ
c) R1R2 = {(1, 2), (1,6), (3, 2), (3, 4), (5, 4), (7, 2)}
d) R1R2 = {(2,2), (3, 2), (3, 4), (5, 1), (5, 3), (7, 1)}

Answer: b
Clarification: By definition, i) R1 = {(1,6), (3,2), (3,4), (3,6), (3,8), (5,6), (7,6)} and ii) R2 = {(1,2), (1,4), (1,8), (5,2), (5,4), (5,8), (7,2), (7,4), (7,8)}. So, R1R2 = Φ.

7. The time complexity of computing the transitive closure of a binary relation on a set of n elements should be ________
a) O(n)
b) O(logn)
c) O(n(n+(3/2)))
d) O(n3)

Answer: d
Clarification: Calculation of transitive closure results into matrix multiplication. We can do matrix multiplication in O(n3) time. There are better algorithms that do less than cubic time.

8. Let A and B be two non-empty relations on a set S. Which of the following statements is false?
a) A and B are transitive ⇒ A∩B is transitive
b) A and B are symmetric ⇒ A∪B is symmetric
c) A and B are transitive ⇒ A∪B is not transitive
d) A and B are reflexive ⇒ A∩B is reflexive

Answer: c
Clarification: In terms of set theory, the binary relation R defined on the set X is a transitive relation if, for all a, b, c ∈ X, if aRb and bRc, then aRc. If there are two relations on a set satisfying transitive property then there union must satisfy transitive property.

9. Determine the characteristics of the relation aRb if a2 = b2.
a) Transitive and symmetric
b) Reflexive and asymmetry
c) Trichotomy, antisymmetry, and irreflexive
d) Symmetric, Reflexive, and transitive

Answer: d
Clarification: Since, x2 = y2 is just a special case of equality, so all properties that apply to x = y also apply to this case. Hence, the relation satisfies symmetric, reflexive and transitive closure.

10. Let R be a relation between A and B. R is asymmetric if and only if ________
a) Intersection of D(A) and R is empty, where D(A) represents diagonal of set
b) R-1 is a subset of R, where R-1 represents inverse of R
c) Intersection of R and R-1 is D(A)
d) D(A) is a subset of R, where D(A) represents diagonal of set

Answer: a
Clarification: A relation is asymmetric if and only if it is both antisymmetric and irreflexive. As a consequence, a relation is transitive and asymmetric if and only if it is a strict partial order. If D(A) is a diagonal of A set and intersection of D(A) and R is empty, then R is asymmetric.

250+ TOP MCQs on Trees – Interconversion for Prefix Postfix Infix Notations

Discrete Mathematics Question Paper on “Trees – Interconversion for Prefix Postfix Infix Notations”.

1. Evaluation of expression a/b+c*d-e in postfix notation.
a) ab+cd/*-e
b) ab/cd*+e-
c) abc/+d*-e
d) abcd/+*-e

Answer: b
Clarification: The expression=a/b+c*d-e
={(ab/)+(cd*)}-e
={(ab/)(cd*)+}-e
={(ab/)(cd*)+}e-
So the output is: ab/cd*+e-

2. Evaluation of 4*5+3/2-9 in prefix notation.
a) *45-/32+9
b) *+453/-29
c) -+*45/329
d) *+/45932

Answer: c
Clarification: The expression=4*5+3/2-9
={(4*5)+(3/2)-9}
={(*45)+(/32)-9}
={+(*45)(/32)}-9
=-{+(*45)(/32)9
So the output is; -+*45/329.

3. What is the output of the following if funct1(7)?

Void main()
{
    int n;
    long int func;
    scanf(“%d”,&n);
    func=func1 (n)
    printf(“%ld!=%ld”,n,func);
}
long int func1(int n)
{
    if(n==0)
    {
        Return 1;
    }
    else
    {
        return(n*func1(n-1));
    }
}

a) 128
b) 4320
c) 720
d) 5040

Answer: d
Clarification: This is a factorial function of an integer using recursive approach. By running the function on integer 7 we get 5040.

4. Infix to prefix conversion can be done using __________
a) two queues
b) two stacks
c) one stack and two queues
d) one stack

Answer: b
Clarification: In the infix expression, the operator appears between the operands and in infix notation if the operator appears before the operands in the expression. For the conversion between them two stacks are used efficiently. The idea is to use one stack for operators and other to store operands.

5. Conversion from prefix to postfix expression can be done _______________
a) using bubble sort
b) using radix sort
c) using two queues
d) in a direct manner

Answer: d
Clarification: In a postfix expression, the operators appear after the operands. Conversion from prefix to postfix is done directly which is better than converting the prefix expression in infix and then infix to postfix expression. It gives better efficiency.

6. What is the postfix expression of 9+3*5/(10-4)?
a) 9 3 + * 5 / 10 4 –
b) 9 3 5 + * / 10 4 –
c) 9 3 + 5 * / 10 4 –
d) 9 3 5 * / + 10 – 4

Answer: c
Clarification: The expression, 9+3*5/(10-4)
= 9+3*5/(10 4-)
= 9+35/*(10 4-)
= 935/*+(10 4-)
So the output is:9 3 5 / * + 10 4 -.

7. What is the postfix expression of (A+B)-C*(D/E))+F?
a) A B + C D E / * – F +
b) A B C D E + / * F – +
c) A B C + * D E / F + –
d) A B + C – * D E / F +

Answer: a
Clarification: The expression is (A+B)-C*(D/E))+F
= (A+B)-C*(DE/)+F
= (A+B)-C*(DE/)F+
= (A+B)-C(DE/)*F+
= (A+B)C(DE/)*-F+
= (AB+)C(DE/)*-F+
So the output is: AB+CDE/*-F+.

8. Convert the following expression into prefix notation.

(g-(f^e/d+c)-ba)

a) ^-/gfed+c-ab
b) -ab/+-ec^dgf
c) -ab-+c/d^efg
d) ab/+-^cde-fg

Answer: c
Clarification: Convert it first in postfix notation, we can have
(g-(f^e/d+c)-ba)
= (g-(f^e/dc+)-ba)
= (g-(f^ed/c+)-ba)
= (g-(fe^d/c+)-ba)
= (g-(fe^d/c+)ba-)
= (gfe^d/c+-ba-)
By reversing this expression gives the prefix expression, i.e
-ab-+c/d^efg.

9. What is the postfix expression of the given expression, (2*4-(5+7/3^4)-8)10?
a) 2 4 5 * 7 3 4 ^ / + 8 – – 10
b) 2 4 * ^ 5 7 3 4 / + 8 10 – –
c) 2 4 * 5 7 ^ 3 4 / + – 8 10 –
d) 2 4 * 5 7 3 4 ^ / + – 8 – 10

Answer: d
Clarification: By solving we can have,
(2*4-(5+7/3^4)-8)10
= (2*4-(5+7/34^)-8)10
= (2*4-(5+734^/)-8)10
= (2*4-(5734^/+)-8)10
= (2*45734^/+–8)10
= 2*45734^/+-8-10
= 24*5734^/+-8-10
So the output is: 2 4 * 5 7 3 4 ^ / + – 8 – 10.

10. Prefix expression can be evaluated _________
a) from right to left
b) from left to right
c) from the exact middle
d) from second right element

Answer: b
Clarification: Expressions are usually evaluated from left to right manner. Prefix expressions follow the normal rule i.e from left to right. Postfix expressions can be evaluated from right to left.