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 (1) .
p → q (p implies q): the proposition “if p, then q,” which is (2) if and only if p
is true and q is false.
(3) is a compound proposition that is always true.
¬q → ¬p is logically (4) to p → q.
∀xP(x) is true if and only if P(x) is true for (5) x in the domain.
The proposition p q is (6) p → q.
𝑝 𝑞 (7)
̅̅̅̅̅̅̅
Answer: (1) true (2) false (3) tautology (4) equivalent (5)
every/each/all (6) the negation of (7) 𝑝̅ 𝑞̅
a. qp
b. pq
c. qp
d. qp
Answer: p q
Comment:
“You get a speeding ticket if you drive at more than 80km/h” q if p.
p q means “q if p”.
Answer: p q
Comment:
Read and try to find words such as “necessary”, “sufficient”, “if”, “only if”,
“if and only if”, …
p q means “q is necessary for p”.
“A necessary condition for [A] is that [B]” means “[B] is necessary for [A]”.
a. pqr
b. (p v r) q
c. pvrvq
d. None of these
Answer: (i)
Comment:
A counter example for (ii) is x = -2.
A counter example for (iii) is x = ½.
No counter example for (i).
5. Let T(x, y) = “the student x takes the class y”, where x represents a student in a
university, and y represents a class.
Translate the logical expression into a sentence:
xyT(x,y)
a. Some students take some classes.
b. Every student takes at least one class.
c. There are some classes that every student takes.
d. Some students take every class.
Answer: b
Comment:
x: every student/each student options (a), (d) are not true.
xyT(x, y) yxT(x, y).
Answer: d
Comment:
xP x xP x
xP x xP x
p q pq
xy M x, y N x, y xy M x, y N x, y
xy M x, y N x, y .
7. Given the premises:
(1) If I eat spicy foods, then I have strange dreams.
(2) I have strange dreams if there is thunder while I sleep.
(3) I did not have strange dreams.
Which conclusion can be drawn?
a. I did not eat spicy foods but there was thunder while I slept.
b. There was thunder while I slept.
c. I ate spicy foods.
d. I did not eat spicy foods and there wasn’t thunder while I slept.
Answer: d
Comment:
(1) e d
(2) t d
(3) d
Apply the rule below to (1)&(3) and to (2)&(3).
(i) p
(ii) q
(iii) p
(iv) F
Answer:
Comment:
Keep in your mind A B A B.
p q (p) q p q.
p q (p) q p q.
(p q) (p q) (p q) (p q) p (q q) p (F) p.
9. Let L(x, y) be the statement “x is a friend of y”, where the domain consists of all people.
Translate the statement “Anybody except one person is a friend of Leo”.
Answer: a
Comment:
Anybody () except one person () is a friend of Leo options (b) and (c)
are not true.
a. (i)
b. (ii)
c. None
d. Both
Answer: (ii)
Comment:
h g g h.
If we know that P(x) is true for every x, then we can conclude that P(x) is true
when x = c.
11.
(i) Any computer science major must take Discrete Mathematics. Anh is taking
Discrete Mathematics. Therefore, Anh is a computer science major.
(ii) Any student of FPT university lives in the dorm. Anh is living in a house.
Therefore, Anh is not a student of FPT university.
a. (i)
b. (ii)
c. None
d. Both
Answer: (ii)
Comment:
h g g h.
(ii) is true due to the rule
Concept review – Chapter 2- SETS, FUNCTIONS, SUMS
b A means b is a/an (1) of the (2) A.
If every element of S is also an element of T, we say S is a (3) of T.
The (4) set, denoted by , is the set with (5) elements.
A B: the (6) of A and B.
A ∩ B: the (7) of A and B.
A − B (the difference of A and B): the set containing elements that are in A (8) in B.
A ⊕ B (the symmetric difference of A and B): the set containing elements in (9) A
and B.
A function from A to B maps (10) element of A to (11) element of B.
If a function is both onto and one-to-one, it is called a (12) .
If a function is a bijection, it has a/an (13) function. Then, it is called an invertible
function.
Answer: (1) element/member (2) set (3) subset (4) null/empty
(5) no (6) union (7) intersection (8) but not (9) exactly one
of (10) each (11) exactly one (12) bijection (13) inverse
1. Let U = {a, b, c, d, e, f, g, h} be the universal set. The bit string representing the set {a, c,
d, f, g} is ____.
a. 01001001
b. 11111100
c. 111111
d. 10110110
Answer: d
Comment:
U has 8 elements a bit string for a set has length 8 option (c) is not true.
Bit string for A:
U a b c d e f g h
A a c d f g
Strings 1 0 1 1 0 1 1 0
2. Let A = {1, 2, 3, 4, 6}, and B = {3, 4, 7} be two sets in the universal set {1, 2, 3, 4, 5, 6,
7}. Find the bit string representing the set A B.
a. 11111111
b. 1100111
c. 1111111
d. 1100011
Answer: b
Comment:
U has 7 elements a bit string for a set has length 7 option (a) is not true.
A B = (AB) – (AB) = {elements which are in A or in B, not both}.
A B = {1, 2, 6, 7}.
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
Answer: 4
Comment:
R = {(-1, -2), (0, -1), (1, 0), (2, 1)}.
Cardinality = number of elements of R.
4. The set A has n elements, B has n+1 elements. Assume that A B has 42 elements. Find
n.
a. 6
b. 7
c. 21
d. 6 or -7
e. None of these
Answer: 6
Comment:
A B has n(n+1) = 42 elements n = 6.
Option (d) is impossible.
5. Given the sequence {an, n = 1, 2, …}: an = 1 + 3 + … + (2n-1).
Find a2019 – a2018.
a. 4037
b. 2019
c. 2018
d. 4038
e. None of these
Answer: 4037
Comment:
a1 = 1, a2 = 1 + (21 – 1), a3 = 1 + 3 + (23 – 1), etc.
an = the sum of n first odd positive integers
a2019 = 1 + 3 + … + (22018 – 1) + (22019 – 1)
a2018 = 1 + 3 + … + (22018 – 1)
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
Answer: 3,
Comment:
11 = (1011)2 three 1-bits a11 = 3.
Answer: A A = A
Comment:
AA=
8. Which rules are functions?
a. f : Z R, f x 1/ x 2 3
b. f : Z Z , f x 1/ x 2 3
c. f : Z Z , f x 1/ x 2 4
d. f : Z R, f x 1/ x 2 4
Answer: a
Comment:
Option (b): f(1) = -1/3 is not in Z.
Option (c), (d): f(2) = 1/0 (!), undefined.
a. (i)
b. (ii)
c. None
d. Both
Answer: d
Comment:
f(x) = x2 – 2x + 1 = (x – 1)2
f(0) = f(2) = 1 not 1-1.
No x such that f(x) = 3 f is not onto.
𝑥 2 −3
10. Let f be the function defined by f(x) = floor( ).
3
Find f(1), f(2) and f(5) (or f({1, 2, 5})).
a. 0, 0, 7
b. -1, 0, 7
c. 0, 1, 8
d. -1, 0, 8
e. None of these.
Answer: -1, 0, 7
Comment:
f(1) = floor(-2/3) = -1.
f(2) = floor(1/3) = 0.
f(5) = floor(22/3) = 7.
11. 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
12. 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.
a. A
b.
c. {}
d. None of these
Answer: x2018 + 2018
Comment:
A = {1, 2}
Subsets of A: , {1}, {2}, {1, 2}
P(A) = { , {1}, {2}, {1, 2} }
AP(A) = { }.
14. 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
Answer: 256
Comment:
P(A) has 2n elements if A has n elements.
2 3
15. Compute i j
i 0 j 1
a. -1
b. -3
c. -9
d. -11
e. None of these.
Answer: -9
Comment:
0 1 0 2 0 3 1 1 1 2 1 3 2 1 2 2 2 3 9
i 0, j from 1 to 3 i 1, j from 1 to 3 i 2, j from 1 to 3
10 20
16. Find the double sum ij .
i 1 j 1
a. 200
b. 231
c. 11550
d. 46200
e. None of these.
Answer: 11550
Comment:
10 20 10 20 10
10
20 21
ij i j i 1 2 ... 20 i i 1 2
i 1 j 1 i 1 j 1 i 1
10
10 11
210 i 210 1 2 ... 10 210 11550 .
i 1 2
Concept Review – Chapter 3 – ALGORITHMS & INTEGERS
a. (i)
b. (ii)
c. Both
d. None
Answer: (ii)
Comment:
g(x) = 3x + 2018 ~ x is O(x2)
(√𝑥 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
Answer: 3
Comment:
(√𝑥 8 +𝑥 4 +1 +1)(𝑙𝑜𝑔𝑥+3) (√𝑥 8 )(𝑙𝑜𝑔𝑥)
~ = x2logx.
𝑥 2 +1 𝑥2
To easily estimate O-notation, keep in your mind the order: 1 < logx < x <
xlogx < x2 < x2logx < x3 < … < 2x < 3x … (for x large enough)
3. Which function is (xlogx)?
a. 2018x
b. x2/2018
c. 20182018
d. None of the others
Answer: x2/2018
Comment:
x2/2018 ~ x2 is (xlogx).
12. Use the function f(x) = (x + 17) mod 26 to encrypt the message CV.
a. CM
b. TM
c. FA
d. TV
e. None of these
Answer: TM
Comment:
A = 0, B = 1, C = 2, …, V = 21, …, Z = 25.
f(x) = (x + 17) mod 26
f(C) = f(2) = 19 = T
f(V) = f(21) = (21 + 17) mod 26 = 12 = M.
13. Suppose the password for a quiz has been encoded using the function f(p) = (p + 13)
mod 26.
If the result is SE, find the quiz password.
a. GP
b. FR
c. HR
d. DM
e. None of these
Answer: FR
Comment:
f(p) = (p + 13) were used to encrypt the quiz password.
We use f-1(p) = (p – 13) mod 26 to decrypt “SA” to obtain the password.
SE = 18 4
f-1(18) = (18 – 13) mod 26 = 5 = F
f-1(4) = (4 – 13) mod 26 = -9 mod 26 = 17 = R.
15. If a, b are positive integers such that gcd(a, b) = 37 and ab = 111111, find lcm(a, b).
a. 4111107
b. 3003
c. 37
d. 1
e. None of the others
Answer:
Comment:
gcd(a, b)lcm(a, b) = ab lcm(a, b) = ab/gcd(a, b) = 111111/37 = 3003.
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
Answer: [1, 3, 2, 4, 5]
Comment:
The initial list is [3, 1, 4, 5, 2].
Some changes when i = 1: [3, 1, 4, 5, 2] (j = 1) [1, 3, 4, 5, 2] (j = 2) [1,
3, 4, 5, 2] (j = 3) [1, 3, 4, 5, 2] (j = 4) [1, 3, 4, 2, 5].
After the 1st pass (i = 1), we have the list [1, 3, 4, 2, 5].
Some changes when i = 2: [1, 3, 4, 2, 5] (j = 1) [1, 3, 4, 2, 5] (j = 2) [1,
3, 4, 2, 5] (j = 3) [1, 3, 2, 4, 5].
After the 2nd pass (i = 2), we obtain the list [1, 3, 2, 4, 5].
Answer: b
Comment:
2. Find a recursive definition for the set of positive integers NOT divisible by 3.
a. 1S,
and xS x+1S, x+2S.
b. 1S,
and xS x+3S.
c. 1S, 2S,
and xS x+3S.
Answer: c
Comment:
Answer: (i)
Comment:
xS
definition
11xS. This means, add “11” before the string x you have.
1S
definition
111S
definition
11111S
definition
1111111S
definition
…
Answer: 9
Comment:
f(n) = f(n/3) + 2.
f(3) = f(3/3) + 2 = f(1) + 2 = 5.
f(9) = f(9/3) + 2 = f(3) + 2 = 7.
f(27) = f(27/3) + 2 = f(9) + 2 = 9.
Answer: c
Comment:
a. 8
b. 16
c. 10
d. None of these.
Answer: 10
Comment:
1A
Comment:
xA x11A.
1A 111A
111A 11111A
etc.
8. To prove the statement " 6 divides n3 - n for all integers n ≥ 0", the mathematical induction
method is used as the following:
(1) The statement is true for n = 0.
(2) Suppose ____, the statement is true, that is, "6 divides k3 - k".
(3) We have, (k+1)3 - (k+1) = (k3 + 3k2 + 3k + 1) - (k + 1) = k3 - k + 3(k2 + k).
a. (i)
b. (ii)
c. None
d. Both
Answer: None
Comment:
a. 1
b. 4
c. 6
d. -1
e. -4
f. -6
Answer: 6
Comment:
f(n) = -f(n - 3)
f(n-3) = -f(n-6)
f(n) = -f(n - 3) = -(-f(n-6)) = f(n-6)
f(2018) = f(2018 – 6) = f(2012)
f(2012) = f(2012 – 6) = f(2006)
f(2006) = f(2000) = … = f(8) = f(2) = 6.
Note that 2018 mod 6 = 2.
10. Give a recursive definition of the set A = {…, -7, -4, -1, 2, 5, 8, …}.
Which of the following definitions is/are true?
(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.
a. (i)
b. (ii)
c. None
d. Both
Answer: Both
Comment:
Start with basic element (2 or -1) other elements can be generated by adding or
subtracting by 3.
Concept Review – Chapter 5-7. COUNTING
1. How many different functions from {a, {a}, b, {a, b}} to {x, y, {z}, y}?
a. 34
b. 43
c. 12
d. Only one
e. 44
Answer: 34
Comment:
{a, {a}, b, {a, b}} has 4 elements.
{x, y, {z}, y} has 3 elements.
2. How many different one-to-one functions from {a, b, c} to {00, 01, 10, 11}?
a. 34
b. 43
c. 4·3·2
d. Only one
Answer: 4·3·2
Comment:
3 steps to set up a function: (1) choose output for a, (2) choose output for b,
(3) choose output for c.
“One-to-one” means the output values are different.
Use product rule to count 4·3·2 one-to-one functions.
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?
a. 5·266 + 5·266 - 25·265
b. 5·5·265
c. 2·5·265
d. 5·266 + 5·266
Answer: 5·266 + 5·266 - 25·265
Comment:
Case 1: Vowel * * * * * * 5·266 words.
Case 2: ******vowel 5·266 words.
Case 3: vowel*****vowel 5·265·5 words.
Note that case 1 includes case 3 and case 2 also includes case 3.
Use inclusion-exclusion principle: case 1 + case 2 – case 3.
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
Answer: 20·19·17
Comment:
Three steps: (1) choose a woman as a president, (2) choose a woman as a vice
president, (3) choose a man as a treasurer.
Use product rule 20·19·17 ways.
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
Answer: 410
Comment:
Ten steps: step 1 – answer the 1st question (4 ways), step 2 – answer the 2nd
question (4 ways), …, step 10 – answer the 10th question (4 ways).
Use product rule 410 ways complete the test.
9. How many integers between 100 and 1000 inclusive that are divisible by 7 or 13?
a. 208
b. 189
c. 188
d. None of these
Answer: 189
Comment:
Case 1: integers in [100, 1000] that are divisible by 7 (128 such integers).
Case 2: integers in [100, 1000] that are divisible by 13 (69 such integers).
Case 3: integers in [100, 1000] that are divisible by both 7 and 13 (8 such
integers).
Case 1 includes case 3 and case 2 also includes case 3.
Use inclusion-exclusion principle (case 1 + case 2 – case 3) Result = 128
+ 69 – 8.
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
Answer: 55,000·1.0315
Comment:
Use the model Pn = Pn-1 + rPn-1 or Pn = (1+r)Pn-1.
P1 = (1+r)P0, P2 = (1+r)P1 = (1+r)2P0
P3 = (1+r)P2 = (1+r)3P0
Pn = P0(1+r)n, where r = 3%, n = 15, P0 = $55,000.
Concept Review – Chapter 8 - Relations
A binary relation from a set A to a set B is a (1) of (2) .
A binary relation on a set A is a (3) of (4) .
There are (5) different relations on a set with n elements.
(a, b) R means a (6) b.
(a, b) R if and only if (b, a) (7) .
(a, b) R if and only if (a, b) (8) .
If R is a relation on the set A and for every element a in A, (a, a) R, then R is called
(9) .
If there are some element a in A such that (a, a) R, then R is (10) .
If there are some a, b, c in A such that aRb, bRc and (11) , then R is not transitive.
A relation on a set A is called a/an (12) if it is reflexive, symmetric and transitive.
2
Answer: (1) subset (2) AB (3) subset (4) AA (5) 2n
(6) aRb (7) R-1 (8) R (9) reflexive (10) not irreflexive (11) a R c
(12) equivalence relation
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
Answer: 3
Comment:
R2 is RR.
(a, b)R and (b, c)R (a, c)R2, etc.
R2 = {(a, c); (c, c); (b, c)}.
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
Which of the three codes is a primary key?
a. size code
b. weight code
c. shape code
d. No primary key
Answer: shape code
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
Answer: (Fran Williams, MTH 202)
Comment:
The projection P1,3(X) helps us to keep the 1st and 3rd components of X and
delete the other components in the 5-tuples X.
4. Suppose R = {(a, b), (b, b), (c, a)} and S = {(a, c), (b, c)} are relations on {a, b, c}.
Construct RS.
a. {(a, c); (b, c)}
b. {(a, a); (b, a)}
c. {(a, a); (b, a); (b, c)}
d. None of these
a. R
b. S
c. None
d. Both
Answer: R
Comment:
Consider the relation S: (8, 3)S (due to 8 – 3 = 5) but (3, 8) S (due to 3 – 8
5) S is not symmetric not b, d.
Consider R: you can see if (8, 3) R (due to 8 – 3 = 5 – the 1st condition) then (3,
8) R (due to 8 = 3 + 5 – the 2nd condition)
If (x, y)R then x – y = 5 or y = x + 5 y = x + 5 or x – y = 5 y – x = 5 or x
= y + 5 (y, x) R R is symmetric.
a. (i)
b. (ii)
c. None
d. Both
Answer: Both
Comment:
a[i, i] = 1 for every index i R is reflexive.
Cannot find i j such that a[i, j] = 1 and a[j, i] = 1 R is anti-symmetric.
a. (i)
b. (ii)
c. None
d. Both
Answer: None
Comment:
a[2, 2] = 0 for every index i R is not reflexive.
a[4,3] = a[3,4] not anti-symmetric.
1 1 1 0
1 1 1 1
8. If M R , determine if R is (a) reflexive (b) symmetric (c) antisymmetric.
0 1 1 0
1 0 0 1
9. Which of these binary relations on the set {1, 2, 3, 4} are equivalence relations?
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (1, 3), (4, 4)}
S = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (4, 4)}
a. S
b. R
c. Both
d. None
Answer: S
Comment:
Check for reflexive property: (3, 3)R R is not reflexive R is not an
equivalence relation.
S is reflexive, symmetric and transitive S is an equivalence relation.
10. How many ordered pairs in the equivalence relation corresponding to the partition {a},
{b, d}, {c} of {a, b, c, d}?
a. 3
b. 4
c. 5
d. 6
e. None of the others
Answer: 6
Comment:
{a}, {b, d}, {c} are classes of this equivalence relation.
The relation must contain (a, a), (b, b), (c, c), (d, d) (due to reflexive property)
The relation must contain (b, d), (d, b) (due to symmetry and b, d are in the
same class).
11. How many different binary relations from {a, b, c} to {1, 2}?
a. 6
b. 8
c. 9
d. 26
e. None of these
Answer: 26
Comment:
Every binary relation from {a, b, c} to {1, 2} is a subset of {a, b, c} {1, 2}.
{a, b, c} {1, 2} = {(a, 1), (a, 2), (b, 1), (b, 2), (c, 1), (c, 2)}.
Count the ways to choose a subset of the set {(a, 1), (a, 2), (b, 1), (b, 2), (c, 1),
(c, 2)}.
By product rule in basic counting techniques, there 222222 = 26 ways.
12. How many different binary relations on {a, b} that contains (a, b)?
a. 1
b. 8
c. 4
d. 16
e. None of these
Answer: 8
Comment:
Every binary relation on the set {a, b} is a subset of {a, b} {a, b}.
{a, b} {a, b} = {(a, a), (a, b), (b, a), (b, b)}.
Count the ways to choose a subset of the set {(a, a), (a, b), (b, a), (b, b)}.
The subset (binary relation) you choose must contain (a, b).
By product rule in basic counting techniques, there 2122 = 8 ways.
Concept review – Chapter 9- GRAPHS
A/an (1) graph is an undirected graph with no multiple edges or loops.
Two vertices are called (2) if there is an edge between them.
An edge is (3) with a vertex if the vertex is an endpoint of that edge.
(4) of a vertex in an undirected graph is the number of edges incident with this
vertex with loops counted twice.
A/an (5) is a path that does not contain an edge more than once.
A/an (6) is a path of length n ≥ 1 that begins and ends at the same vertex.
A/an (7) graph is the undirected graph with n vertices where each pair of vertices is
connected by an edge.
Graph Km,n has (8) edges and (9) vertices.
Graph Wn has (10) edges and (11) vertices.
A matrix representing a graph using the adjacency of vertices is called (12) of the
graph.
A matrix representing a graph using the incidence of edges and vertices is called (13)
of the graph.
A graph with vertex set that can be partitioned into subsets V1 and V2 so that each edge
connects a vertex in V1 and a vertex in V2 is called a/an (14) graph.
A circuit that contains every edge of a graph exactly once is called a/an (15) .
A simple path in a graph that passes through each vertex exactly once is called a/an (16).
Answer: (1) simple (2) adjacent (3) incident (4) degree (5) simple path
(6) circuit (7) connected (8) m.n (9) m + n (10) 2n (11) n +1
(12) adjacency matrix (13) incidence matrix (14) bipartite (15) Euler
circuit (16) Hamilton path
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.
Answer: None
Comment:
The sum of degrees of all vertices in a undirected graph = 2*(the number
of edges)
(5 + 5 + 4 + 3 + 2 + 1 + 1 + 1 + 0) = 2*(the number of edges)
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
Answer: None
Comment:
Study (i), 3 vertices of odd degrees no such a graph.
Two vertices of degree 5 each of other vertices (4 vertices) has at least
degree 2 (ii) is impossible to be a degree sequence of a simple graph (a
graph with no loop, no multiple edge).
a. K6
b. C6
c. W6
d. Q3
e. None of these
Answer: K6
Comment:
An adjacency matrix has the size of nn, where n is the number of
vertices.
The size of the matrix is 66 the graph has 6 vertices.
Q3 has 8 vertices, W6 has 7 vertices.
From the matrix, vertex 1 is adjacent to each of vertices {2, 3, 4, 5, 6}
the matrix is not for C6.
4. How many 1-entries in the adjacency matrix of graph K3,5?
a. 15
b. 30
c. 8
d. None of these
Answer: 30
Comment:
K3,5 is a complete bipartite graph with 8 vertices.
K3,5 has 3*5 = 15 edges.
Number of 1s = 2*number of edges.
Adjacency matrix of K3,5 is
1 2 3 4 5 6 7 8
1 0 0 0 1 1 1 1 1
2 0 0 0 1 1 1 1 1
3 0 0 0 1 1 1 1 1
4 1 1 1 0 0 0 0 0
5 1 1 1 0 0 0 0 0
6 1 1 1 0 0 0 0 0
7 1 1 1 0 0 0 0 0
8 1 1 1 0 0 0 0 0
a. n is an integer.
b. n is an even integer.
c. n is an odd integer.
d. No such n.
Answer: n is an even integer
Comment:
Let use two colors to color every vertex of Cn.
Try with C4, C5 to see a conclusion.
Answer: No – Yes
Comment:
Yes for (i) Yes for (ii)
A Hamilton path: h-i-d-e-a-c-b-g-k-l-m-j-f
Answer: No – No
Comment:
Yes for (i) Yes for (ii)
No for (ii) No for (i)
If there is at least one vertex of odd degree No for (i)
The graph has 4 vertices of odd degree No for (ii)
11. Find the length of an Euler circuit in the graph K9 or state that K9 has no an Euler
circuit.
a. 18
b. 9
c. 45
d. 36
e. K9 has no an Euler circuit.
Answer: 36
Comment:
K9: a simple graph with 9 vertices of degree 8.
EVERY VERTEX has EVEN DEGREE K9 has an Euler circuit.
The length of a path = number of edges.
K9 has C92 36 edges.
An Euler circuit is a circuit that passes through every edge exactly once
An Euler circuit in K9 passes through 36 edges of K9, exactly once for
each.
G H
a. G
b. H
c. Both
d. None
Answer: H
Comment:
Color each of 4 vertices of the graph, start form an arbitrary vertex (e.g.,
vertex 1).
Use two colors (Red, Blue) (or two states 0, 1).
Adjacent vertices different colors/states.
Check out the adjacency of vertices of the same color.
Let consider the graph G:
vertex 1 2 3 4
Color/state Red Blue Red Blue
So, {2, 4} are vertices of the same color.
Let check out the adjacency of vertices 2 and 4 vertex 2 and vertex 4
are adjacent G is NOT bipartite.
13. List all positive integers m and n such that Km,n has a Hamilton circuit.
a. m = n.
b. m = n > 1.
c. |m – n| = 1.
d. m and n are even.
e. None of these
Answer: m = n > 1
Comment:
There is NO criteria to know whether a graph has a Hamilton circuit.
14. Find the length of an Euler circuit in the graph W7 or state that it has no an Euler
circuit.
a. 7
b. 8
c. 14
d. W7 has no an Euler circuit.
Answer: d
Comment:
To have an Euler circuit, a graph must be connected and EVERY
VERTEX of this graph has EVEN DEGREE.
A graph with at least one vertex of ODD DEGREE has no an Euler
circuit.
W7: a wheel with a center (degree 7) and 7 other vertices (degree 3).
15. How many cut vertices does the graph below have?
a. 0
b. 1
c. 2
d. 3
e. 4
Answer: 4
Comment:
A vertex is called cut vertex if deleting this vertex makes a disconnected
graph.
Cut vertices are b, c, e, i.
a. 3
b. 6
c. 9
d. 12
Answer: 6
Comment:
Let A be the adjacency matrix of the given graph.
To count the number of path of length 2, you have to compute A2.
You can only do this: multiply <row a> of A by <column c> of A.
a. 27
b. 9
c. 28
d. 32
e. None of these
Answer: 28
Comment:
Let A be the adjacency matrix of the given graph.
To count the number of path of length 3, you have to compute A3.
To see the result, read the number at the (row b, column c)-entry.
You can only do this: multiply <row b> of A2 (respectively, A) by
<column c> of A (respectively, A2).
18. Use Dijkstra's Algorithm to find the shortest path length from a to z in the following
weighted graph. How many vertices are not used?
a. 1
b. 2
c. 3
d. 4
e. None of these
Answer: 1
Comment:
The shortest path is a-b-e-d-z and b is not used.
Concept review – Chapter 10 - TREES
A tree is a connected undirected graph with no (1) .
An m-ary tree is a tree with the property that every internal vertex has (2) children.
A full m-ary tree is a tree with the property that every internal vertex has (3) children.
A tree with n nodes has (4) edges.
A full m-ary tree with i internal vertices has (5) nodes and (6) 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 (7) .
(8) 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.
(9) is the form of an expression obtained from a preorder traversal of the tree
representing this expression.
(10) is the form of an expression obtained from a post-order traversal of the tree
representing this expression.
Answer: (1) simple circuit (2) exactly 2 (3) exactly m (4) n – 1 (5) mi + 1
(6) (mi + 1 – i) (7) prefix code (8) Preorder traversal (9) Prefix
notation/form (10) Postfix notation/form
Answer: 198
Comment:
Number of edges = number of nodes – 1 = n – 1.
“Binary” means m = 2.
Solve the system n = i + l (for every tree) and n = mi + 1 (for full m-ary
tree only) where n (l, i) stands for number of nodes (leaves, internal
nodes).
Answer: 11
Comment:
Solve the system n = i + l (for every tree) and n = mi + 1 (for full m-ary
tree only) where n (l, i) stands for number of nodes (leaves, internal
nodes).
3. Construct a binary search tree for the words: TIME, AND, TIDE, WAIT, FOR, NO,
MAN. How many comparisons are used to locate the word “MAN”?
a. 3
b. 4
c. 5
d. 6
e. None of these
Answer: 6
Comment:
Start by adding the word “TIME” to the tree.
The word “MAN” is also needed to compare to itself.
4. How many comparisons are used to locate the word “ending” in the binary search
tree for the words of the sentence “A bad beginning makes a bad ending”?
a. 2
b. 3
c. 4
d. 5
e. None of the others
Answer: 5
Comment:
Start by adding the word “A” to the tree.
The same position for the same word (A, bad).
The word “ending” is also needed to compare to itself.
a. (i)
b. (ii)
c. None
d. Both
Answer: (ii)
Comment:
Study the code scheme (i), 101 is for B and 101 is also a prefix of 1011,
the one is for D.
Answer: (i)
Comment:
Study the code scheme (ii), 11 is for A and 11 is also a prefix of 1101, the
one is for C.
Answer: eat
Comment:
Start “reading” 10111001 from left to right
101 is for e, 11 is for a, 001 is for t.
8. What is the code for the word “keep” if the coding scheme is represented by the
following tree?
a. 1000010011110
b. 1010001001111
c. 00100111101101
d. 110000100111110
e. None of these
Answer: 110000100111110 (d)
Comment:
Start from the root to go to the leaf node.
From the tree above, 1100 is for k, 001 is for e, 1110 is for p.
9. What is the average number of bit required to encode the word “nobody” using
Huffman coding algorithm?
a. 8/3
b. 2
c. 7/3
d. 2.5
e. None of these
Answer: 7/3
Comment:
First, count the frequency of each character and list them in an increasing
order (n(1) b(1) d(1) y(1) o(2)).
Construct a binary tree using Huffman algorithm.
10. What is the average number of bits 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
Answer: 13/7
Comment:
First, count the frequency of each character and list them in an increasing
order (u(1) e(1) c(2) s(3)).
Construct a binary tree using Huffman algorithm.
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?
a. 3.15
b. 2.45
c. 2.25
d. 3.45
e. None of these
Answer: 2.25 bits/symbol
Comment:
Always choose 2 trees of least weights from the forest.
After constructing the binary tree for the given data, the number of bits for
each character is given as below: 2 bits for a, 3 bits for b, 3 bits for c, 2 bits
for d and 2 bits for e.
Average number of bits for each character can be calculated as follow:
Ave = sum(number of bits of a character * frequency of this character) =
2*0.20 + 3*0.10 + 3*0.15 + 2*0.25 + 2*0.30 = 2.25.
12. Find the value of the expression + - 7 * 2 1 / 3 1
a. 4
b. 6
c. 8
d. 10
e. None of these
Answer: 8
Comment:
An operator (+) is in the first position, it follows that the expression is in
prefix form.
From right to left, find a triple in form <operator> <number 1>
<number 2> (for example, / 3 1) to compute <number 1> <operator>
<number 2>.
Answer: 2
Comment:
14. Find the postfix form of the infix 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
Answer: a
Comment:
The expression includes only one / option (b) is not true. In the postfix
form, the root node (an operator) is visited last. So, the last symbol is
always an operator (+, -, *, /, …) option (c) is not true.
In the expression (2*x + y)/(x – 3*y), the last operator is /, and therefore
the postfix form ends with /.
The expression tree is shown as below