DMPNS

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

Discrete Mathematics 5CCM251A Exercise Sheet 1

Semester 2 – 2023/24

1. The sequence (Fn ) of Fibonacci numbers is defined by setting F0 = 1, F1 = 1 and

Fn = Fn−1 + Fn−2 , for all n ≥ 2.

Prove by induction that that


n−1
X
Fi2 = Fn−1 Fn , for all n ≥ 1.
i=0

2. (i) Verify that 26 − 1 and 36 − 1 are both divisible by 7. Deduce directly, i.e. without appealing to
Fermat’s Little Theorem, that a7 ≡ a mod 7 for any integer a.
(ii) Determine 2n−1 mod n for all 3 ≤ n ≤ 19 by hand, as efficiently as you can. (You may use
Fermat’s Little Theorem.)

3. Prove by induction that an = 6n + 7n is the solution of the equation an = 13an−1 − 42an−2 , n ≥ 2,


with a0 = 2 and a1 = 13.

4. (i) With the help of Fermat’s Little Theorem, or otherwise, find the smallest positive remainder r
when 229 is divided by 7.
(ii) The decimal representation of 229 consists of nine distinct digits. Assuming this fact, use
addition modulo 9 to find which digit is missing.

5. What are the last 4 digits of 38007 ?

6. (i) Use the Euclidean algorithm to find gcd(341, 190).


(ii) Find integers x, y such that 341x + 190y = gcd(x, y) (now check your answer by using a
different method, e.g. use the matrix method if you didn’t before).
(iii) Use the Euclidean algorithm to find integers a, b, c for which 42a ≡ 1 mod 5, 35b ≡ 1 mod 6,
and 30c ≡ 1 mod 7.
(iv) Hence, or otherwise, find all integers x that satisfy the simultaneous equations:

x≡2 (mod 5), x ≡ 1 (mod 6), x ≡ 2 (mod 7).

7. A group of schoolers are taking part in a parade. They decide to file in queues. When they file in
queues of 4, two persons remain. When they file in queues of 5, three persons remain. And, when
they files in queues of 7, five persons remain. What is the smallest number of schoolers taking part in
the parade?

8. With the help of a computer, find the last three decimals of 31234567 . (Do not try to print this number
on your screen, it’s too big! You can use Sage or any package of your choice.)

9. Challenge puzzle: Fix a prime p. Using induction on a, prove that, for all a ∈ N,

ap = a mod p.

(i.e. prove Fermat’s Little Theorem for this prime p). Hint: You will need to use the binomial
expansion of (a + 1)p .

1
Discrete Mathematics 5CCM251A Exercise Sheet 2
Semester 2 – 2023/24

1. Solve the second-order recurrence relation

an − an−1 − 20an−2 = 40n, n ≥ 2,

with starting values a0 = − 11 91


10 and a1 = − 10 .

2. Find a particular (i.e. any) solution of the recurrence relation

an = 2an−1 − an−2 + 1, n ≥ 2.

Now find the solution of the same relation satisfying a0 = a1 = 1.

3. Find a formula for the solution of the recurrence relation


a2n−1
an = , n ≥ 2,
an−2
with a0 = 1 and a1 = 2. [Hint: define bn = lg(an ) and find a linear recurrence that bn satisfies]

4. The Tower of Hanoi is a famous puzzle consisting n discs of different sizes, with holes at their
centres, and of three vertical poles, onto which the discs can be slipped. Initially all the discs are on
one of the poles, in order of size, with the largest at the bottom, forming a tower. It is required to
move the discs, one at a time, finishing up with the n discs similarly arranged on one of the other
poles. Th ere is the important requirement that at no stage may any disc be placed on top of a smaller
disc. What is the minimum number of moves required?
Let an denote the least number of moves in which the n-disc puzzle can be solved. Determine a1 , a2
and a3 . Show that n discs can be transferred in 2an−1 + 1 moves (and no fewer), and deduce a
formula for an .

5. The function g : N −→ N is defined recursively by g(0) = 0, g(1) = 1, and


(
g(n/2) + 1 for even n ⩾ 2
g(n) =
g(3n + 1) + 1 for odd n ⩾ 3.

Verify by hand that g(12) = g(13). Compute g(11).

1
6. In a football competition, there are n qualifying groups. At the next stage of the competition, each
winner of a group plays a runner up in another group. In how many ways can the winners and the
runners up be paired?
!
0 1
7. Let M = and Fn be the n-th Fibonacci number.
1 1

(a) Prove that !


n+2 Fn Fn+1
M = .
Fn+1 Fn+2
2
(b) By taking determinants show that Fn Fn+2 − Fn+1 = (−1)n .
(c) By considering the identity M m+n+2 = M m+1 M n+1 , prove that

Fm+n = Fm Fn + Fm−1 Fn−1 .

8. Challenge problem:

(a) Show that each n ⩾ 1 can be written as a sum of distinct non-consecutive Fibonacci numbers,
e.g. 73 = 55 + 13 + 5, 140 = 89 + 34 + 13 + 3 + 1.
(b) Show that this representation is unique, i.e. for each n ⩾ 1 there is only one way of writ-
ing n as a sum of distinct non-consecutive Fibonacci numbers (it is called the Zeckendorf
decomposition).

2
Discrete Mathematics 5CCM251A Exercise Sheet 3
Semester 2 – 2023/24

1. (a) Express 168 in binary.


(b) Use your answer in (a) to compute 7168 mod 11 by hand, using the fast exponentiation algo-
rithm from lectures.

2. Determine how many steps Euclid’s Algorithm requires in order to compute (up to and including the
step in which the remainder is zero.)

(a) gcd(90, 55);


(b) gcd(89, 55).

3. Explain which of the following relationships are true and which are false (here n ∈ N):

(a) n2 = O(3n2 + 10n + 1);


(b) n2 = O(0.01n3 );
(c) n3 = O(3n2 + 10n + 1);
(d) exp(n) = O(n10 );
(e) log n = O(n0.01 ).

4. A gardener has to plant a column of n rose bushes (where n is an integer at least 2). The roses come
in three varieties (red, blue, yellow). The gardener must obey the following rules:

• the first and last bush must be red;


• no two colours can be adjacent in the column.

Let rn denote the number of valid ways the gardener can plant n rose bushes. For example, it turns
out that r7 = 22, and below are the 22 possible columns:

(i) Find a way of expressing rn using a recurrence formula of order 1.


(ii) Hence, or otherwise, work out a closed formula for rn in terms of n.

5. Determine the number of distinct permutations of each of the following types of the set {1, 2, . . . , n}.

(a) n-cycles

1
(b) (n − 1)-cycles
(c) (n − 2)-cycles

Can you determine the number of (n − k)-cycles for k ≤ n?

6. Challenge problem. The sum of the first perfect n squares is given by


n
X n(n + 1)(2n + 1)
j2 = .
2
j=1

(a) Using the big O-notation, estimate in terms of n the number of bit operations required to
perform the computations in the left hand side of the equality.
(b) Estimate in terms of n the number of bit operations required to perform the computations in the
right hand side of the equality.

2
Discrete Mathematics 5CCM251A Exercise Sheet 4
Semester 2 – 2023/24

Discrete Mathematics is a Model 1 module this year. This means that there are no participation marks.
But you can submit questions to get feedback from your TA. If you want to do so, please submit
the questions marked with a (*). The submission deadline is Friday 23 February 2024 at 4pm.

1. Tutorial activity: In pairs (or in threes if there is an odd number of people in your tutorial group),
test each other on the definitions of the following terms. One point for each correct answer. Next
tutorial test each other again (again, one point for each correct answer). Add up scores for both
rounds. Highest total wins.

(i) graph
(ii) simple graph
(iii) digraph
(iv) subgraph
(v) (vertex)-induced subgraph
(vi) complete graph
(vii) bipartite graph
(viii) graph isomorphism
(ix) degree
(x) δ(G)
(xi) ∆(G)
(xii) adjacent
(xiii) joins
(xiv) walk
(xv) trail
(xvi) path
(xvii) closed walk/trail/path
(xviii) cycle
(xix) connected graph
(xx) components
(xxi) disconnecting set
(xxii) cut set
(xxiii) bridge
(xxiv) tree
(xxv) forest
(xxvi) Eulerian graph

1
(xxvii) semi-Eulerian graph
(xxviii) Hamiltonian graph

2. Consider the three regular graphs below, each with eight vertices. Determine whether any two of
them are isomorphic, justifying your answer.

3. How many simple connected non-isomorphic graphs are there with four vertices? Represent them
pictorially, making certain that no two are isomorphic. [It helps to start with K4 as there cannot be
more than 6 edges].

4. (*) Describe an isomorphism from the Petersen graph, as defined near the start of Section 4 of the
notes with vertex set
V1 = {12, 13, 14, 15, 23, 24, 25, 34, 35, 45},
and the graph below with V2 = {0, 1, . . . , 9}. You will need to define a bijection V1 → V2 that
respects adjacency. All you have to do is label the vertices below as 12, 13, . . . , 45 so that two are
joined if and only if the pairs of numbers are disjoint.

5. (*) Consider the cycle graph Cn , the wheel graph Wn (meaning n vertices in total), and the complete
graph Kn . Which of them are Eulerian and for which values of n?

2
6. This question asks you to explain one of the examples from the lecture notes. Ask your tutor if you
need some explanation of what a domino is! (It is very old-fashioned game in the UK, these days).

(i) Let G be the graph obtained from the complete graph K7 by adding a loop at each vertex.
Explain why G is Eulerian.
(ii) A standard set of 28 dominoes is illustrated below. Deduce from (i) that it is possible to place
the 28 dominoes end-to-end legitimately (so each two join with matching pips) in a line starting
with a 6 at one end and a 6 at the other. [Hint: label each edge of G with one of the dominoes.]

3
Discrete Mathematics 5CCM251A Exercise Sheet 5
Semester 2 – 2023/24

Discrete Mathematics is a Model 1 module this year. This means that there are no participation marks. But
you can submit questions to get feedback from your TA. If you want to do so, please submit the questions
marked with a (*). The submission deadline is Monday 4 March 2024 at 4pm.

1. Describe a semi-Eulerian trail (meaning a trail that passes along every edge exactly once) in the
following graph. Is the graph Eulerian? Justify your answer.

2. A simple connected graph G has five vertices. Which of the following additional properties would
imply that G is not planar? [Hint: It might help to draw some planar graphs with 5 vertices.]

(i) G has ten edges;


(ii) G has nine edges;
(iii) G has at least ten different subgraphs that are isomorphic to a 3-cycle;
(iv) G has at least two different subgraphs that are isomorphic to a 4-cycle;
(v) G has at least two different subgraphs that are isomorphic to a 5 cycle.

3. Describe, by name or by drawing a diagram, all the graphs (up to isomorphism) that one can obtain
from K5 , K3,3 and W6 by contracting a single edge. [Note: W6 is the wheel graph with 6 vertices,
one of which has degree 5, so unlike the other graphs not all its edges are equivalent.]

4. (*) Determine whether the following graphs are planar or not. [Note: the second graph has only 8
vertices (it is not W9 )].

1
More precisely:

(i) if you think that one of the graphs is planar you should exhibit a planar drawing of it and
describe why your drawing is a planar drawing. [Hint: try selecting chords to move outside the
outer cycle in turn.]
(ii) If you succeed in showing that one of the graphs is not planar (by any argument), please also
exhibit a subgraph that is homeomorphic to K5 or to K3,3 .

5. (*) Use Kuratowki’s theorem to deduce that the Chvátal graph (shown below) is not planar. [Hint:
you just have to throw away a few edges and vertices to get a more familiar graph.]

6. The locked trio of rings adopted by the Borromeo family is shown below. In this question, interpret
the crossings as vertices of degree 4, so that the resulting graph G has 6 vertices and 12 edges. (In
fact, G is isomorphic to the octahedral graph.)

2
Now let G+ denote the graph obtained from G by adding an extra edge joining vertices a and b
without any extra vertex. Draw your own diagram of G+ and show that

(i) G+ has a subgraph homeomorphic to K5 ;


(ii) G+ also has a subgraph isomorphic to K3,3 .

[Hint: for (i), it might be helpful to notice first that a and b belong to a subgraph of G+ isomorphic
to K4 . A subgraph like this, it isomorphic to a complete graph, is called a ‘clique’.]

7. Question for advanced understanding: Modify the argument from the printed notes, in your own
words, to show that if a simple planar graph has no 3-cycles and e ≥ 4 then e ≤ 2n − 4. [ Bear in
mind that an edge usually bounds 2 faces, but sometimes only 1.] Deduce that K3,3 is not planar.

3
Discrete Mathematics 5CCM251A Exercise Sheet 6
Semester 2 – 2023/24

Discrete Mathematics is a Model 1 module this year. This means that there are no participation marks. But
you can submit questions to get feedback from your TA. If you want to do so, please submit the questions
marked with a (*). The submission deadline is Monday 11 March 2024 at 4pm.

1. This question is about the famous maze at Hampton Court Palace. In the diagram below, the hedges
are marked in green and the walkway is marked in light-orange.

(i) Use the diagram below to draw a graph of the maze, using the following rules: Label the ‘start’
at the bottom by adding a vertex outside the maze; label the ‘finish’ with a vertex in the centre
of the maze; add a vertex at each dead-end (all these vertices will have degree 1); label the
junctions with vertices of degree 3. Number all the vertices, with the start labelled as ‘1’.

(ii) Carry out a DFS search from vertex ‘1’. List the vertices in the other they are found, and draw
the DFS tree spanning tree with ‘1’ as its root.

2. Repeat question 1 (ii) using BFS search. Is the order of the vertices different? Are the spanning trees
different? If not, why not?

3. (*)

(i) Apply the greedy algorithm to the vertices of the following graph G in ascending numerical
order (starting from ‘1’) to produce a vertex colouring:

1
(ii) Apply instead a version of Brooks’ algorithm: apply the BFS algorithm starting at vertex 3
(which has degree 2), adding smaller labels to the queue first. Then apply the greedy colouring
algorithm to colour the vertices in reverse order.

(iii) What is the chromatic number χ(G)?

4. (*) Consider the Grötzsch graph G below with 11 vertices.

(i) Is it regular?
(ii) What does Brooks’ theorem tell you about its chromatic number χ(G)?
(iii) Apply the greedy algorithm to colour (using α, β, γ, . . .) the vertices of G in descending
numerical order, starting with ‘10’. Does the outcome imply that χ(G) = 4?

5. Try to find cycles of a given length n in the Grötzsch graph G. For what values of n ≥ 3 does there
exist an n-cycle? Is G Hamiltonian?

2
Discrete Mathematics 5CCM251A Exercise Sheet 7
Semester 2 – 2023/24

Discrete Mathematics is a Model 1 module this year. This means that there are no participation marks. But
you can submit questions to get feedback from your TA. If you want to do so, please submit the questions
marked with a (*). The submission deadline is Monday 18 March 2024 at 4pm.

1. (*) Consider graph below.

16

6 11

1 10
17
12 20
2 15
7 5

3 4
13
9
14
8
18 19

(i) Run a BFS search starting from vertex 1.


(ii) Using the result in (i), colour the graph using Brook’s algorithm for non regular graphs.

2. Consider the graph below.

(i) Apply Dijkstra’s algorithm to determine the shortest ‘distance’ of every other vertex from 1.
(ii) Highlight a spanning tree with the property that it contains a shortest path from 1 to each of the
other vertices. Re-draw the tree with 1 as the root at the top. What is its total weight?
(iii) Use Kruskal’s algorithm to find a minimal spanning tree, and then re-draw the MST with 1 at
the top. What is its total weight?

1
1
2 2
3
1 4
3
5
3 5
6 7
1 2 3

3. (*)

(i) Apply Dijkstra’s algorithm to determine the shortest ‘distance’ of every other vertex from 1.
(ii) Highlight a spanning tree with the property that it contains a shortest path from 1 to each of the
other vertices. Re-draw the tree with 1 as the root at the top. What is its total weight?
(iii) Use Kruskal’s algorithm to find a minimal spanning tree, and then re-draw the MST with 1 at
the top. What is its total weight?

2 4
9

8
28 8 10 5
7 7
8
1 1 26 7
5 6
1
2 24 8
27

4. Let G = (V, E) be a graph with n vertices and n − 1 edges, with n ≥ 2. We assume that none of the
vertices in V is isolated. Show that G contains at least two vertices of degree 1.

5. The graph below is called Flower Graph 7.

2
15
22
8
16 28
9 21
23 1
14
2
7

10 3 6 27
17
13 20
24
4 5
11
12
26
18 25
19

(i) Run a DFS search starting from vertex 1.


(ii) Using the result in (i), colour the graph using Brook’s algorithm.
(iii) After you have finished colouring the flower graph, make it a present to your mom for Mother’s
Day. [Hint. A late present is always better than no present at all!]

3
Discrete Mathematics 5CCM251A Exercise Sheet 8
Semester 2 – 2023/24

Discrete Mathematics is a Model 1 module this year. This means that there are no participation marks. But
you can submit questions to get feedback from your TA. If you want to do so, please submit the questions
marked with a (*). The submission deadline is Monday 25th March 2024 at 4pm.

1. In the following network, encircled numbers represent capacities.

(i) What is the greatest value a flow can have?


(ii) Start with the zero flow, so that f (e) = 0 for all edges. Apply one iteration of the Labelling
Algorithm and update the flow. Is a second iteration sufficient to determine a maximum flow?
a b
5

4 4

s 2 1 t

10 9

c 8
d

2. (*) Use the Labelling Algorithm to determine a maximum flow from s to t within the network below.
Start with a flow on the path s → a → d → e → t with 5 units on each arc and 0 on all the other
arcs (so this initial flow has value 5), and augment it with two iterations:

a d
5

10 8 5 20

s 4 c 8 t

15 10 3 5

14 e
b

(i) Continuing question 1, apply a third iteration so as to reach as many vertices as the rules allow.
When you reach each vertex x in the queue, remember to ‘scan’ adjacent (previously unseen)
vertices with non-zero flow towards x. Hence, or otherwise, find a minimum cut.
(ii) Do the same for the network in question 2.

3. Consider the following network with vertex set V, in which encircled numbers again represent
capacities. List all the cuts V = S ⊔ T for which the subgraphs induced by S and T (obtained by
removing all the edges across the cut) are connected. [Since s ∈ S and t ∈ T = V \ S, it suffices to
list the subsets S ∩ {a, b, c, d}.] For each such cut, find its capacity. Is there a unique minimum cut?

1
a b
5

4 4

s 2 1 t

10 9

c 8
d

4. Consider the network and the flow f below.

(a) Show that C1 := s → a → b → t is an augmenting path for f , and compute the flow f1
obtained by augmenting f through C1 .
(b) Show that C2 := s → d → c → e → t is an augmenting path for f1 , and compute the flow f2
obtained by augmenting f1 through C2 .
(c) Show that C3 := s → d → c → t is an augmenting path for f2 , and compute the flow f3
obtained by augmenting f2 through C3 .
(d) Find an augmenting path C4 for f3 and the corresponding flow f4 which maximises f . What is
the value of f4 ?

2 b
a 4
1 3
3 0 5 6
5 2
1 1
s c
3 5 t
4 2
12 7 0 3
3 6
3
d 5
e

5. (*) Consider the network and the zero flow f0 = 0 below. Using the Labelling Algorithm, find a
maximal flow starting with f0 .

2
0 b
a 4
0 0
0 0 5 6
5 2
0 0
s c
3 5 t
0 0
12 7 0 0
3 6
0
d 5
e

3
Discrete Mathematics 5CCM251A Exercise Sheet 9
Semester 2 – 2023/24

Discrete Mathematics is a Model 1 module this year. This means that there are no participation marks. But
you can submit questions to get feedback from your TA. If you want to do so, please submit the questions
marked with a (*). The submission deadline is April 15th March 2024 at 4pm.

1. Alice publishes her RSA key: the modulus 𝑛 = 1073 and the exponent 𝑒 = 5.

(a) Bob wants to send the message 𝑚 = 101 to Alice. What ciphertext must he send?
(b) Knowing that one the primes that divides Alice modulus is 𝑝 = 29, find the secret exponent 𝑠
of Alice.
(c) Alice receives the ciphertext 𝑐 = 730 from Bob. Decipher the message.

2. (*) The goal of this exercise is to show how doing modular arithmetic can become quickly expensive.
This is a nice application of the Chinese Remainder Theorem. Let 𝑝 = 101, 𝑞 = 263 and 𝑛 = 26563.
Let the public exponent of Bob be 𝑒 = 7.

(a) Alice wants to send the message 𝑎 = 275 to Bob. Compute the ciphertext 𝑐.
(b) Compute the secret exponent 𝑠.
(c) Try to compute the plaintext text 𝑎 by applying the decryption function to 𝑐 directly. Can your
calculator do it?
(d) Compute 𝑠𝑝 = 𝑠 mod 𝑝 − 1 and 𝑠𝑞 = 𝑠 mod 𝑞 − 1; 𝑐𝑝 = 𝑐 mod 𝑝 and 𝑐𝑞 = 𝑐 mod 𝑞; and
𝑠 𝑠
𝑚𝑝 = 𝑐𝑝𝑝 mod 𝑝 and 𝑚𝑞 = 𝑐𝑞 𝑞 mod 𝑞.
(e) Using the Chinese Remainder Theoreom, compute 0 ≤ 𝑚 ≤ 𝑛 − 1 such that 𝑚 = 𝑚𝑝 mod 𝑝 and
𝑚 = 𝑚𝑞 mod 𝑞. Verify that 𝑚 = 𝑎.

[Note that all the calculations in (d) and (e) can be done on your calculator!]

3. Alice uses an RSA key whose modulus is 𝑛 = 𝑝𝑞 = 172205490419. By espionage, Oscar discovers
that (𝑝 − 1)(𝑞 − 1) = 172204660344. Determine 𝑝 and 𝑞.

4. Bob receives the ciphertext 𝑏 sent by RSA. This ciphertext encrypts the plaintext 𝑎. Suppose that by
some ruse Eve could make Bob decrypt the ciphertext 𝑐 which is not the same as 𝑏. How can Eve
recover the message 𝑎?

5. (*) In this exercise, we take 𝑝 = 5, 𝑞 = 13 and 𝑒 = 7. We use the alphabet  =  = ℤ∕65ℤ.

1
A B C D E F G H I J K L M
0 1 2 3 4 5 6 7 8 9 10 11 12

N O P Q R S T U V W X Y Z
13 14 15 16 17 18 19 20 21 22 23 24 25

. ? ␣ ’ _ ! @ ^ , ( ) $ #
26 27 28 29 30 31 32 33 34 35 36 37 38

a b c d e f g h i j k l m
39 40 41 42 43 44 45 46 47 48 49 50 51

n o p q r s t u v w x y z
52 53 54 55 56 57 58 59 60 61 62 63 64

(a) Compute the secret exponent 𝑠.


(b) Using the above RSA scheme, your friend sends you the following ciphertex: “taYYC)EaIHRrV”.
Which of these is the most appropriate reply? “Go to hell!” or “Same to you!”.
(c) Encrypt your reply using the key 𝑠 and the RSA scheme above.

You might also like