AMTH140 Assignment 4
This assignment covers second-order recurrence relations, recursion, and graph theory, including: trails, paths, circuits, graph isomorphism, and matrix representations of graphs.
Question 1:
[30 marks]
Solve the following second-order linear homogeneous recurrence relations with constant coefficients.
(a) an = −4an−1 − 4an−2 for all integers n ≥ 2 with a0 = 0, and a1 = −1.
(b) an = an−1 + 6an−2 for all integers n ≥ 2 with a0 = 0, and a1 = 3.
Question 2:
[5 marks]
Consider the following function f : Z+ → Z for all positive integers:
n − 10
if n > 100
f (n) =
f (f (n + 11)) if n ≤ 100
Find f (99), f (100), and f (101).
Question 3:
[30 marks]
(a) For the graph in Figure 1, determine whether the following walks are trails, paths, closed
walks, circuits, simple circuits, or just walks.
1. v1 e2 v2 e3 v3 e4 v4 e5 v2 e2 v1 e1 v0
2. v2 v3 v4 v5 v2
3. v4 v2 v3 v4 v5 v2 v4
4. v2 v1 v5 v2 v3 v4 v2
5. v0 v5 v2 v3 v4 v2 v1
6. v5 v4 v2 v1
1
Figure 1: Graph for Question 3(a).
(b) Determine whether the graph in Figure 2 has an Euler circuit. If it does, describe one.
If it does not, explain why not.
(c) Determine whether each graph in Figure 3 has a Hamiltonian circuit. If it does, describe
one. If it does not, explain why not by making use of Proposition 10.2.6 on the existence
of subgraphs of graphs with Hamiltonian circuits.
Question 4:
[20 marks]
Consider the following adjacency matrix:
0 1 1
1 0 2
1 2 1
(a) Draw the graph corresponding to this adjacency matrix.
(b) How many walks of length 1, 2, and 3 are there from v1 to v1 ?
(c) How many walks of length 3 are there from v2 to v3 ?
Question 5:
[15 marks]
Determine whether the two graphs in Figure 4 are isomorphic. If they are, give the vertex
set mapping g : V (G) → V (G0 ), and the edge set mapping h : E(G) → E(G0 ) that define the
isomorphism. If they are not, give an invariant for the graph isomorphism that they do not
share.
2
Figure 2: Graph for Question 3(b).
Figure 3: Graphs for Question 3(c).
3
Figure 4: Graphs for Question 5.
4
AMTH140 Assignment 5
This assignment covers trees, including examples and characterization of trees; and analysis
of algorithms, including O, Ω, and Θ notations.
Question 1:
[10 marks]
Using Backus-Naur notation, a grammatically correct sentence can be generated using the
following rules:
1. hsentencei → hnoun phraseihverb phrasei
2. hnoun phrasei → harticleihnouni
3. hverb phrasei → hverbihnoun phrasei
(a) Represent these rules as a parse tree.
(b) Following these rules, generate all possible sentences with harticlei → the, hnouni →
cow|grass, and hverbi → ate.
(c) All sentences in (b) should have correct syntax. Which of these sentences also has the
correct semantics?
Question 2:
[20 marks]
Use the theorems on graphs and trees to help you with this question.
(a) Either draw a tree with 5 vertices and total degree 10, or explain why no such graph
exists.
(b) Either draw a connected graph that has a circuit, 7 vertices, and 6 edges; or explain why
no such graph exists.
(c) Either draw a graph that is circuit-free, has 7 vertices, and 4 edges; or explain why no
such graph exists.
(d) A connected graph has 11 vertices and 10 edges. Does it have a vertex of degree 1?
1
Question 3:
[20 marks]
Apply insertion sort (from Tutorial 6) to sort the list 4, 15, 36, 30, 3, 9.
(a) How does the algorithm know when the list is sorted?
(b) What is the maximum number of comparisons required for a list of six numbers?
(c) How many comparisons did you actually require for the given list?
Question 4:
[25 marks]
Use the definitions of the O, Ω, and Θ notations (but not the general theorem on polynomial
orders) to show that:
(a)
x2 + 25x + 4,
is Θ(x2 ). Show your reasoning.
(b)
1 3
x − 50x − 12,
2
is O(x3 ). Show your reasoning.
Question 5:
[25 marks]
(a) Use mathematical induction to prove that log2 n ≤ n for all integers n ≥ 1.
(b) O, Ω, and Θ notations are also used for functions defined on the set of non-negative
integers (i.e., sequences). Use the result in part (a) to show that
3n + log2 n,
is Θ(n). Show your reasoning.
2
Purchase answer to see full
attachment