Concept Review - Chapter 1-10
Concept Review - Chapter 1-10
• p ∨ q (disjunction of p and q): the proposition “p or q,” which is true if and only
if at least one of p and q is ___.
• p → q (p implies q): the proposition “if p, then q,” which is ___ if and only if p is
true and q is false.
• ___ is a compound proposition that is always true.
• ¬q → ¬p is logically ___ to p → q.
• ∀xP(x) is true if and only if P(x) is true for ___ x in the domain.
• The proposition p q is ____ p → q.
• State the De Morgan’s Laws.
• 𝑝𝑞𝑟
̅̅̅̅̅̅̅̅̅̅̅
a. Any hardworking student is good in class. An is not good in class. Therefore An was not
working hard.
b. Anyone in class understands logics. An is a student in class. Therefore An understands
logics.
c. Any computer science major must take Discrete Mathematics. An is taking Discrete
Mathematics. Therefore An is a computer science major.
d. Any student of FPT university lives in the dorm. An is living in a house. Therefore An is
not a student of FPT university.
Concept review – Chapter 2- SETS, FUNCTIONS, SUMS
• b A means b is a/an ____ of the ____ A.
• If every element of S is also an element of T, we say S is a ____ of T.
• The ___ set is the set with ____ elements.
• A ∪ B: the ____ of A and B.
• A ∩ B: the ____ of A and B.
• A − B (the difference of A and B): the set containing elements that are in A ___ in B.
• A ⊕ B (the symmetric difference of A and B): the set containing elements in ____ A and
B.
• A function from A to B maps ____ element of A to ____ element of B.
• If a function is both onto and one-to-one, it is called a ____.
• If a function is a bijection, it has an ____ function. It’s also called an invertible function.
1. Let U = {a, b, c, d, e, f, g, h, i, j}. The bit string representing the subset {a, c, d, g, h, i} is
____
a. 10 1110 1110
b. 10 1101 1110
c. 10 1100 1011
d. 10 1100 1110
2. Let U = {a, b, c, d, e, f, g, h, i, j}.
Given the subsets A = {a, c, d, e, i}, B = {a, f, g, h, j}. The bit string representing the
subset A - B is_______
a. 01 0110 0010
b. 00 1011 0010
c. 00 1110 0010
d. 00 0111 1010
3. Let R be the set {(a, b) | a - 1 = b}, where a and b are in {-2, -1, 0, 1, 2}. How many
elements does R have? (or in other words, what is the cardinality of R?)
a. 4
b. 3
c. 2
d. 1
4. The set A has n elements, B has n+1 elements. Assume that A B has 42 elements. Find
n.
Answer: n = 6
5. Given the sequence {an, n = 1, 2, …}: an = 1 + 2 + 3 + … + n. Find a7 – a6.
a. 7
b. 6
c. 1
d. n
e. None of these
6. Given the sequence {an, n = 1, 2, …} where an equals the number of 1 bits in the
binary format of n. Find a11.
a. 0
b. 1
c. 2
d. 3
e. 4
f. None of these
7.
Answer: (i)
10.
12. Find the composite function (fg)(x) = f(g(x)), where f(x) = x + 2018 and g(x) = x2018.
a. (x+2018)2018
b. x2018 + 2018
c. x2018(x+2018)
d. None of these
13. Given A = {1, 2}. Find A - P(A). (Recall that P(A) is the power set of A)
a.
b. A
c. { }
d. None of these
14. Given A = {1, 2}, find A P(A).
a. A
b.
c. { }
d. None of these
15. How many elements does the set P({1, 2, 3, 4, 5, 6, 7, 8}) have?
a. 8
b. 16
c. 256
d. None of these
16.
Answer: (i)
17.
10 11 20 21
Answer:
2 2
19. Which sum is largest?
Concept Review – Chapter 3 – ALGORITHMS & INTEGERS
a. (i) only
b. (ii) only
c. Both
d. None
(√𝑥 8 +𝑥 4 +1 +1)(𝑙𝑜𝑔𝑥+3)
2. Find the least integer k such that is O(xk).
𝑥 2 +1
a. 1
b. 2
c. 3
d. 4
e. None of these
3. Which function is (xlogx)?
a. 2018x
b. x2/2018
c. 20182018
d. All of the above
4. Given f(x) = 3x2 + 12x + 2 and g(x) = x3
Which statement is True?
a. f(x) is O(g(x))
b. f(x) is (g(x))
c. f(x) is (g(x))
d. None of these
5. Suppose a mod 4 = 3 and b mod 8 = 7, find ab mod 4.
a. 1
b. 2
c. 3
d. 21
e. 9
6. Which of the following integers are congruent to 13 modulo 7?
a. -6
b. -1
c. 1
d. 7
e. None of these
7. Consider the algorithm:
procedure giaithuat(a1, a2, …, an : integers)
count:= 0
for i:= i to n do
if ai > 0 then count: = count + 1
print(count)
Give the best big-O complexity for the algorithm above.
a. O(n)
b. O(logn)
c. O(1)
d. O(n2)
e. None of these
8. Consider the algorithm:
procedure GT(n : positive integer)
F:=1
for i:= 1 to n do
F: = F * i
Print(F)
Give the best big-O complexity for the algorithm above.
a. O(n)
b. O(logn)
c. O(1)
d. O(n2)
e. None of these
9. Find the base 7 expansion of 186
a. 354
b. 331
c. 413
d. 271
e. None of these
10. Find the binary format of (1011)3.
a. 11110
b. 11111
c. 100000
d. 10101
e. None of these
11. Suppose pseudo-random numbers are produced by using:
xn+1 = (3xn + 5) mod 7.
If x3 = 5, find x2 and x4.
Answer: x4 = 6, x2 = 0
12. Suppose pseudo-random numbers are produced by using:
xn+1 = (3xn + 7) mod 13 and the seed x1 = 1.
Find x3 and x4.
Answer: x3 = 11 and x4 = 1.
13. Use the function f(x) = (x + 17) mod 26 to encrypt the message CV.
Answer: TM
14. Suppose the password for a quiz has been encoded using the function f(p) = (p + 13)
mod 26.
If the result is TA, find the password for the quiz.
Answer: GN
15. Which pair of integers are relatively prime?
a. (17, 51)
b. (5, 24)
c. (11, 121)
d. (37, 111)
e. None of the others
16. If a, b are positive integers such that gcd(a, b) = 5 and ab = 120, find lcm(a, b).
a. 24
b. 600
c. 120
d. 5
e. None of the others
17. Consider the bubble sort algorithm:
bubblesort(a1, a2, ..., an: integers)
for i:= 1 to n-1
for j:= 2 to n-i
if aj+1 < aj then swap(aj, aj+1)
If the input is [3, 1, 4, 5, 2], what is the result after the second pass (i = 2)?
a. [1, 2, 3, 4, 5]
b. [1, 3, 2, 4, 5]
c. [2, 1, 3, 4, 5]
d. [1, 3, 2, 5, 4]
e. None of these
18. Consider the Linear search algorithm:
procedure linear search(x: integer, a1, a2,..., an: distinct integers)
i := 1
while (i ≤ n and x ai )
i := i + 1
if i ≤ n then location := i
else location := 0
return location
if x ∈ A, then x11 ∈ A
a. (i)
b. (ii)
c. None
d. Both
9. Find f (2018) if f (n) = - f(n - 3) and f (0) = 1, f (1) = 4, f(2) = 6.
a. 1
b. 4
c. 6
d. -1
e. -4
f. -6
10. Give a recursive definition of the set A = {…, -7, -4, -1, 2, 5, 8, …}
(i) 2 ∈ A; if x ∈ A then x + 3 ∈ A or x – 3 ∈ A
(ii) -1 ∈ A; if x ∈ A then x + 3 ∈ A or x – 3 ∈ A
Which is true?
a. (i)
b. (ii)
c. None
d. Both
Concept Review – Chapter 5-7. COUNTING
1. How many different function from {a, {a}, b, {a, b}} to {x, y, {z}, y}?
a. 34
b. 43
c. 12
d. Only one
e. 44
2. How many different one-to-one function from {a, b, c} to {00, 01, 10, 11}?
a. 34
b. 43
c. 4·3·2
d. Only one
3. Suppose that a “word” is any string of seven letters of the alphabet, with repeated letters
allowed.
How many words begin with A or B and end with A or B?
a. 2.265
b. 4.265
c. 266
d. None of these
4. Suppose that a “word” is any string of seven letters of the alphabet, with repeated letters
allowed. How many words begin with a vowel or end with a vowel?
Answer: (5·266 + 5·266 - 25·265)
5. A club with 20 women and 17 men needs to choose three different members to be
president, vice president, and treasurer. In how many ways is this possible if women will
be chosen as president and vice president and a man as treasurer?
a. 20 · 19 · 17
b. 37 · 36 · 35
c. 20 · 17 · 16
d. None of these
6. Find the number of subset of {1, 2, 3, 4, 5, 6} that contain 3.
a. 26
b. 25
c. 5
d. None of these
7. Suppose a restaurant serves a “special dinner” consisting of soup, salad, entree, dessert,
and beverage. The restaurant has five kinds of soup, three kinds of salad, ten entrees, five
desserts, and four beverages. How many different special dinners are possible? (Two
special dinners are different if they differ in at least one selection.)
a. 5 · 3 · 10· 5· 4
b. 5 + 3 + 10 + 5 + 4
c. 25
d. None of these
8. A professor teaching a Discrete Math course gives a multiple choice quiz that has ten
questions, each with four possible responses: a, b, c, d. How many ways for a student to
complete the test? (Assume that no answers are left blank.)
a. 40
b. 104
c. 410
d. None of these
9. How many integers between 100 and 1000 inclusive that are divisible by 7 or 13?
a. 142 + 75 – 9
b. 142 + 75
c. 143 + 75 – 9
d. None of these
10. Suppose f (n) = 4 f (n/2) if n is divisible by 2, and f (1) = 2. Find f (8).
a. 226
b. 128
c. 256
d. 64
e. None of these
11. You take a job that pays $55,000 annually. How much do you earn 15 years from now if
you receive a three percent raise each year?
a. 55,000·1.0315
b. 55,000·0.0315
c. 55,000·1.1315
d. 55,0001.03
e. None of these
Concept Review – Chapter 8 - Relations
• A binary relation from a set A to a set B is a ____ of ____.
• There are ____ different relations on a set with n elements.
• (a, b) R means a ___ b.
• (a, b) R if and only if (b, a) ___.
• (a, b) R if and only if (b, a) ___.
• If there are some element a in A such that (a, a) R, then R is ___.
• If there are some element a in A such that (a, a) R, then R is ___.
• If there are some a, b, c in A such that aRb, bRc and ____, then R is not transitive.
• A relation on a set A is called a/an ___ if it is reflexive, symmetric and transitive.
1. If R = {(a, b), (b, c), (c, c)}, how many ordered pairs are there in R2?
a. 1 b. 2 c. 3 d. 4 e. none of these
2. A company makes four kinds of products. Each product has a size code, a weight code,
and a shape code. The following table shows these codes:
Size Code Weight Code Shape Code
42 27 42
27 38 13
13 12 27
42 38 38
Find which of the three codes is a primary key.
a. size code
b. weight code
c. shape code
d. No primary key
3. If X = (Fran Williams, 617885197, MTH 202, 248B West), find the projection P1,3(X).
a. (Fran Williams, MTH 202)
b. (617885197, 248B West)
c. (Fran Williams, 617885197)
d. None of these
4. Suppose R = {(a, b), (b, b), (c, a)} and S = {(a, c), (b, c)} are relations on {a, b, c}.
Construct RoS.
a. {(a, c); (b, c)}
b. {(a, a); (b, a)}
c. {(a, a); (b, a); (b, c)}
d. None of these
5. Let R = {(x, y) | x – y = 5 or y = x + 5} and S = {(x, y) | x – y = 5} are relations on the set
of integers. Which one is true?
(i) R is symmetric
(ii) S is symmetric
a. (i)
b. (ii)
c. None
d. Both
6. Given a matrix of a relation R
1. How many edges are there in an undirected graph with degree sequence 5, 5, 4, 3, 2,
1, 1, 1, 0?
a. 21
b. 20
c. 10
d. 11
e. No such a graph.
2. Which degree sequence corresponds to a simple graph?
(i) 5, 4, 3, 2, 1
(ii) 5, 5, 4, 2, 1, 1
a. (i)
b. (ii)
c. None
d. Both
3. Which graph corresponds to the following adjacency matrix?
a. K6
b. C6
c. W6
d. Q3
e. None of these
4. How many 1-entries in the adjacency matrix of graph K3,5?
a. 15
b. 30
c. 8
d. None of these
5. Cn is bipartite if and only if
a. n is an integer.
b. n is an even integer.
c. n is an odd integer.
d. No such n.
6. Are these two graphs isomorphic?
a. 0
b. 1
c. 2
d. 3
e. 4
16. How many paths of length 2 from a to c in the graph below?
a. 3
b. 6
c. 9
d. 12
17. How many paths of length 3 from b to c?
a. 6
b. 9
c. 12
d. 15
e. None of these (40 paths)
18. Use Dijkstra's Algorithm to find the shortest path length between the vertices b and
z in this weighted graph. How many vertices are not used?
a. 1
b. 2
c. 3
d. 4
e. None of these
Concept review – Chapter 10 - TREES
• A tree is a connected undirected graph with no ____.
• An m-ary tree is a tree with the property that every internal vertex has ____ children.
• A full m-ary tree is a tree with the property that every internal vertex has ____ children.
• A tree with n nodes has ____ edges.
• A full m-ary tree with i internal vertices has ____ nodes and ____ leaves.
• A code that has the property that the code of a character is never a prefix of the code of
another character is called a ____.
• ____ is a listing of the vertices of an ordered rooted tree defined recursively - the root is
listed, followed by the first subtree, followed by the other subtrees in the order they occur
from left to right.
• ____ is the form of an expression obtained from a preorder traversal of the tree
representing this expression.
• ____ is the form of an expression obtained from a post-order traversal of the tree
representing this expression.
a. 1000010011110
b. 1010001001111
c. 00100111101101
d. 110000100111110
e. None of these
9. What is the average number of bit required to encode the word “nobody” using
Huffman coding algorithm?
a. 2.15
b. 2.25
c. 2
d. 2.5
e. None of these (14/6)
10. What is the average number of bit required for each letter when using Huffman
coding algorithm to encode the word “success”?
a. 13/7
b. 15/7
c. 2
d. 16/7
e. None of these
11. Use Huffman coding to encode these symbols with given frequencies: a: 0.20, b:
0.10, c: 0.15, d: 0.25, e: 0.30. What is the average number of bits required to encode a
character?
Answer: 2.25 bits/symbol
12. Find the value of the expression + - 7 * 2 1 / 3 1
a. 4
b. 6
c. 8
d. 10
e. None of these
13. Find the value of the expression 5 4 - 3 6 3 / 7 - *.
a. 2
b. 4
c. 6
d. 8
e. None of these
14. Find the postfix form of the expression (2*x + y)/(x – 3*y).
a. 2 x * y + x 3 y * / /
b. 2 * x y + x 3 / y * /
c. / + * 2 x y / x * 3 y
d. None of these