124ms
Sets and Logic
Coursework 2 (2013–2014)
1
Notes
Notes
1. The module code is 124ms, and the module title is Sets and Logic.
2. our assignment should be submitted at the hand-in point in the Engineering and
Computing Building by 16:00 on 23th July 2014. Note that work handed in later than
this without attached evidence of an extension/deferral will be given a mark of 0.
3. Work should be secured by a staple at the top left hand corner. Do not put it in a plastic
wallet or a binder. If it is printed, it should be double-sided.
4. Remember that you must have a barcoded cover sheet and two copies of your
assignment, one of which you submit along with the cover sheet, and the other for
your own records.
5. This is an individual assignment, not a group assignment. Collaborating on the
assignment will be regarded as cheating.
6. This assignment is worth 60% of the module mark.
2
Assessment Criteria
To obtain a first class mark, you should submit work that is technically correct (with at most
minor slips) and is fully explained in grammatically correct standard English. (Due
consideration will be made for students with relevant registered disabilities, such as
dyslexia.)
So for example, notation should be correct, and any deviations from the notation used in
class should be explained. If you present a truth or membership table, part of the credit will
be for explaining where the table comes from, part for correct entries, and part for an
explanation of how the table does its job. If you present a formal proof, you should clearly
explain what are the hypotheses, and what is the conclusion; the proof should be presented
in the standard (tabular) manner, and you should give a brief explanation to show that the
proof does what it is supposed to. If you use a standard algorithm, you should explain what
happens at each step.
A bare pass would normally be awarded for a submission which shows that a serious
attempt, with at least some success, has been made to understand the relevant mathematics
and apply it appropriately.
A marks breakdown is shown on the assignment, and a full worked solution and marking
scheme will be provided after the hand-in deadline.
1
Attempt ALL seven questions
1. The functions f : {1, 2, 3} → { a, b} and g : { a, b} → { x, y, z} are given by f (1) = b,
f (2) = b, f (3) = a, g( a) = y, g(b) = x.
(a) Classify each of f and g as bijective, injective, surjective, or neither.
(b) Find g ◦ f .
(c) Either find the inverse of g ◦ f or explain why g ◦ f is not invertible.
(8 marks)
2. I want to develop a database of information about my book collection, which tells me
about the authors and genres of the various books I own. At the moment I have books
by Isaac Asimov, China Mieville, Peter F Hamilton and Arthur C Clarke, and I denote
the set of authors by A = { A, M, H, C }, abbreviating each author by the initial of his
surname. I am classifying the books as science fiction, fantasy, horror and non-fiction,
so my set of genres is G = {s, f , h, n}, again using initial letters as abbreviations.
At the moment, I have science fiction works by China Mieville and Isaac Asimov, I
have fantasy by Peter F Hamilton and China Mieville, horror by Peter F Hamilton and
Arthur C Clarke, and non-fiction by Isaac Asimov.
(a) Give the relation R on A × G which represents this information. (You may use
appropriate abbreviations.)
(b) Find the combination of projection and inverse projection maps which finds all
authors by whom I have horror books.
(c) Find the combination of projection and inverse projection maps which find all
writers who have written non-fiction or fantasy books in my collection.
(8 marks)
2
3.
(a) Draw the graph with adjacency matrix
A=
0
0
0
1
1
0
0
1
0
0
0
1
0
1
1
1
0
1
0
1
1
0
1
1
0
where the columns and rows label vertices 1 to 5 in order.
(b) Use the adjacency matrix connectivity algorithm, starting by marking row 1 and
crossing out column 1, to show whether this graph is connected.
(c) Calculate A2 and hence find the number of paths of length 2 from vertex 1 to
vertex 5.
(d) Find a breadth first spanning tree starting at vertex 3.
(11 marks)
4. Use Dijkstra’s algorithm to find the shortest path from node a to node f in the
following graph.
c
3
b
3
5
2
7
a
d
12
2
4
f
e
(8 marks)
5. Use the heapsort algorithm to put the following list of numbers in decreasing order:
8 2 4 7 1 3 5
You should explain in detail how the original heap is obtained, and then show your
sequence of heaps and partial ordered lists.
(8 marks)
3
6. Consider the symbols and frequencies:
o : 12 e : 10 n : 4 t : 6 s : 5 m : 3
(a) Find a Huffman code for this situation, and the average length of an encoded
symbol.
(b) Assign the symbols to these codewords in a different order, and comment on the
resulting average length.
(9 marks)
7. Bob decides to use n = 221 = 13 × 17 and e = 11 as his public key for an RSA
cryptosystem.
(a) Show that the decryption exponent is 35.
(b) Find the encrypted form of the message 16.
(8 marks)
RJL,124ms\coursework\cw2jan.tex
4
124ms
Sets and Logic
Coursework 2 (2013–2014)
1
Notes
Notes
1. The module code is 124ms, and the module title is Sets and Logic.
2. our assignment should be submitted at the hand-in point in the Engineering and
Computing Building by 16:00 on 23th July 2014. Note that work handed in later than
this without attached evidence of an extension/deferral will be given a mark of 0.
3. Work should be secured by a staple at the top left hand corner. Do not put it in a plastic
wallet or a binder. If it is printed, it should be double-sided.
4. Remember that you must have a barcoded cover sheet and two copies of your
assignment, one of which you submit along with the cover sheet, and the other for
your own records.
5. This is an individual assignment, not a group assignment. Collaborating on the
assignment will be regarded as cheating.
6. This assignment is worth 60% of the module mark.
2
Assessment Criteria
To obtain a first class mark, you should submit work that is technically correct (with at most
minor slips) and is fully explained in grammatically correct standard English. (Due
consideration will be made for students with relevant registered disabilities, such as
dyslexia.)
So for example, notation should be correct, and any deviations from the notation used in
class should be explained. If you present a truth or membership table, part of the credit will
be for explaining where the table comes from, part for correct entries, and part for an
explanation of how the table does its job. If you present a formal proof, you should clearly
explain what are the hypotheses, and what is the conclusion; the proof should be presented
in the standard (tabular) manner, and you should give a brief explanation to show that the
proof does what it is supposed to. If you use a standard algorithm, you should explain what
happens at each step.
A bare pass would normally be awarded for a submission which shows that a serious
attempt, with at least some success, has been made to understand the relevant mathematics
and apply it appropriately.
A marks breakdown is shown on the assignment, and a full worked solution and marking
scheme will be provided after the hand-in deadline.
1
Attempt ALL seven questions
1. The functions f : {1, 2, 3} → { a, b} and g : { a, b} → { x, y, z} are given by f (1) = b,
f (2) = b, f (3) = a, g( a) = y, g(b) = x.
(a) Classify each of f and g as bijective, injective, surjective, or neither.
(b) Find g ◦ f .
(c) Either find the inverse of g ◦ f or explain why g ◦ f is not invertible.
(8 marks)
2. I want to develop a database of information about my book collection, which tells me
about the authors and genres of the various books I own. At the moment I have books
by Isaac Asimov, China Mieville, Peter F Hamilton and Arthur C Clarke, and I denote
the set of authors by A = { A, M, H, C }, abbreviating each author by the initial of his
surname. I am classifying the books as science fiction, fantasy, horror and non-fiction,
so my set of genres is G = {s, f , h, n}, again using initial letters as abbreviations.
At the moment, I have science fiction works by China Mieville and Isaac Asimov, I
have fantasy by Peter F Hamilton and China Mieville, horror by Peter F Hamilton and
Arthur C Clarke, and non-fiction by Isaac Asimov.
(a) Give the relation R on A × G which represents this information. (You may use
appropriate abbreviations.)
(b) Find the combination of projection and inverse projection maps which finds all
authors by whom I have horror books.
(c) Find the combination of projection and inverse projection maps which find all
writers who have written non-fiction or fantasy books in my collection.
(8 marks)
2
3.
(a) Draw the graph with adjacency matrix
A=
0
0
0
1
1
0
0
1
0
0
0
1
0
1
1
1
0
1
0
1
1
0
1
1
0
where the columns and rows label vertices 1 to 5 in order.
(b) Use the adjacency matrix connectivity algorithm, starting by marking row 1 and
crossing out column 1, to show whether this graph is connected.
(c) Calculate A2 and hence find the number of paths of length 2 from vertex 1 to
vertex 5.
(d) Find a breadth first spanning tree starting at vertex 3.
(11 marks)
4. Use Dijkstra’s algorithm to find the shortest path from node a to node f in the
following graph.
c
3
b
3
5
2
7
a
d
12
2
4
f
e
(8 marks)
5. Use the heapsort algorithm to put the following list of numbers in decreasing order:
8 2 4 7 1 3 5
You should explain in detail how the original heap is obtained, and then show your
sequence of heaps and partial ordered lists.
(8 marks)
3
6. Consider the symbols and frequencies:
o : 12 e : 10 n : 4 t : 6 s : 5 m : 3
(a) Find a Huffman code for this situation, and the average length of an encoded
symbol.
(b) Assign the symbols to these codewords in a different order, and comment on the
resulting average length.
(9 marks)
7. Bob decides to use n = 221 = 13 × 17 and e = 11 as his public key for an RSA
cryptosystem.
(a) Show that the decryption exponent is 35.
(b) Find the encrypted form of the message 16.
(8 marks)
RJL,124ms\coursework\cw2jan.tex
4
Purchase answer to see full
attachment