Final exam review

CSC 10400: Discrete Mathematical Structures (Spring 2015)
Final Exam review
Name: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Problem
1
2
3
4
5
6
7
8
9
10
11
Total
Score
There are 11 questions in exam. Each of them is worth 10 points. You can
choose 10 of them. If you answer all 11 questions, the extra one will be considered
as a bonus question.
Good Luck!
1
1. There are 40 balls in a box. These balls have five colors: red, blue, yellow, white and
black. Each color involves 8 balls. Percy draws 10 balls from the box.
(a) In how many ways these 10 balls have all of 5 colors?
Answer:
Let c1 , c2 , . . . , c5 be the conditions corresponding to that the drawn balls does not
have one color. This problem asks the number of elements satisfying none condition.
Thus, we have
N = S0 − S1 + S2 − S3 + S4 − S5
First, S0 is the number of ways selecting 10 balls from 40 balls; i.e, S0 = 40
10 . Second,
.
N (c1 ) is the number of ways selecting 10 balls from non-red balls; i.e., N (c1 ) = 32
10
5 16
5 24
5 32
By symmetric, S1 = 1 10 . Similarly, S2 = 2 10 , S3 = 3 10 , and clearly,
S4 = S5 = 0.
5 32
5 24
5 16
Thereofre, N = 40
10 − 1 10 + 2 10 − 3 10 .
(b) In how many ways these 10 balls have exactly 3 colors?
Answer:
We also define c1 , c2 , . . . , c5 as the conditions corresponding to that the drawn balls
does not have one color. This problem asks the number of elements satisfying exactly
two condition.
3
4
5
E2 = S2 −
S3 +
S4 −
S5
1
2
3
5 24
3 5 16
=
−
2 10
1 3 10
2
2. Find the unique solution of the following recurrence relation.
a0 = 2; a1 = 6; an − 6an−1 − 7an−2 = 0, n > 1
Answer:
The characteristic equation is r2 − 6r − 7 = 0. Solve this quadratic equation, we obtain
two roots: r1 = 7 and r2 = −1. Thus, the general solution is:
an = q1 (7n ) + q2 ((−1)n )
From a0 = 2, we have a0 = q1 + q2 = 2. From a1 = 6, we have a1 = 7q1 − q2 = 6. Thus,
q1 = 1 and q2 = 1. Therefore, the unique solutions is:
an = 7n + (−1)n
3. Find the unique solution of the following recurrence relation.
a0 = 3; an − 4an−1 = 6(4n ), n > 0
Answer:
The corresponding homogeneous recurrence relation is
an − 4an−1 = 0
Thus, we have hn = α(4n ). Because 6(4n ) is a specified solution of hn , we set pn = βn(4n ).
Replace pn into an − 4an−1 = 6(4n ), we have βn(4n ) − 4β(n − 1)(4n−1 ) = 6(4n ). Divide
4n−1 from both sides, we have 4βn − 4β(n − 1) = 6 × 4 = 24, implying 4β = 24, i.e.,
β = 6. Thus, the general solutions is:
an = hn + pn = α(4n ) + 6n(4n ) = (α + 6n)4n
From a0 = 3, we have a0 = α = 3. Therefore, the unique solution is:
an = (3 + 6n)4n
3
4. Let G be an undirected graph shown in the following figure.
(a) Give an example of a trail from a to c which is not a path.
Answer:
There are lots of solutions. One of them is a → b → f → e → b → c.
(b) Give an example of a path from a to d.
Answer:
There are lots of solutions. One of them is a → b → c → d.
(c) Give an example of a circuit from a to a which is not a cycle.
Answer:
There are lots of solutions. One of them is a → b → f → c → e → f → a.
(d) Give an example from a cycle from a to a.
Answer:
There are lots of solutions. One of them is a → b → f → a.
(e) The number of components in G is
2
4
.
5. Let G be an undirected graph shown in the following figure.
f
g
h
i
j
a
b
c
d
e
(a) Draw the subgraph of G induced from the set of vertices {a, b, c, e, f, i, j}.
Answer:
f
a
i
b
c
j
e
(b) Is G planar? Why?
Answer:
No, it is not planar. This graph contains a subgraph K3,3 , shown in the following
figure.
f
a
i
c
5
j
e
6. Let G be an undirected graph show in the following figure.
(a) Does G have an Euler circuit? Why?
Answer:
No, it does not have an Euler circuit, because the degree of b and c are both 3.
(b) Does G have a Hamiltonian cycle? If it has, draw a Hamiltonian cycle.
Answer:
Yes, it has a Hamiltonian cycle, shown in the following figure. (This is not the unique
solution.)
6
7. Let G = (V, E) be a graph shown in the following figure.
(a) Determine a sequence of visited vertices in a Depth-first Search (DFS) algorithm
starting from the vertex a.
Answer:
For example, a, b, c, d, e, f, g
(b) Determine a sequence of visited vertices in a Breadth-first Search (BFS) algorithm
starting from the vertex a.
Answer:
For example, a, b, f, c, e, d, g.
7
8. Let T be an tree with root node a shown in the following figure.
(a) The parent of h is
c
.
(b) The children of f are
l, m, n
(c) The siblings= of j are
i, k
(d) The vertices at the level 2 are
(e) The leaves in the tree are
.
.
e, f, g, h, i, j, k
.
e, g, i, k, l, m, n, o, p, r, s, u
8
.
9. Let T be an tree with root node a shown in the following figure.
(a) List the nodes in the preorder traversal of T .
Answer:
The preorder traversal of T is
a, b, e, k, l, m, f, g, n, r, s, c, d, h, o, i, j, p, q
(b) List the nodes in the postorder traversal of T .
Answer:
The postorder traversal of T is
k, l, m, e, f, r, s, n, g, b, c, o, h, i, p, q, j, d, a
9
10. Let T be a tree with root node a shown in the following figure.
(a) List the nodes in the inorder traversal of T .
Answer:
The inorder traversal of T is:
b, a, f, d, g, k, c, h, e, l, i
(b) Draw the subtree of T at the vertex d.
Answer:
The subtree of T at the vertex d is drawn in the following figure.
10
11. Suppose that letters a, b, c, d, e, f have weights shown in the following table.
a
45
b
13
c
12
d
16
e
9
f
5
Construct a Huffman code for given weights and draw the corresponding complete binary
tree.
Answer:
The complete binary tree is shown in the following figure.
A Huffman code associated with this tree is:
a
0
b
101
c
100
d
111
11
e
1101
f
1100