COMP11120
Two hours
UNIVERSITY OF MANCHESTER
SCHOOL OF COMPUTER SCIENCE
Mathematical Techniques for Computer Science
Date: Wednesday 1st June 2016
Time: 09:45 - 11:45
Please answer all THREE Questions.
Use a SEPARATE answerbook for each SECTION.
This is a CLOSED book examination
The use of electronic calculators is permitted provided they
are not programmable and do not store text
[PTO]
, COMP11120
Section A
1. a) Prove the following statement by induction: (4 marks)
n n(n + 1) 2
∑ i3 = 2
.
i=0
b) Recall the recursively defined notion of a list over a set S, and the length function
on such lists given by
Base case len. len [ ] = 0
Step case len. len(s : l) = 1 + len l.
i) Give a recursive definition for a function rpt that takes as input a list over Z
and returns another such list, where each element of the list is repeated. The
expected output of this function for the list [2, 1, 3], for example, is
(3 marks)
[2, 2, 1, 1, 3, 3].
ii) In the notes there is a Java class List which is the direct counterpart of a
recursively defined list. For this class give a method that implements the
function described in part (i) by filling in the two return cases in the following
Java program. (3 marks)
public static List rpt (List l)
{
if (l == null)
return
else
return
}
iii) Prove by induction that for all lists l over S we have (5 marks)
len(rpt l) = 2 len l.
c) Show by induction that for all n ∈ N, (5 marks)
8n − 3n is divisible by 5.
Page 2 of 6
Two hours
UNIVERSITY OF MANCHESTER
SCHOOL OF COMPUTER SCIENCE
Mathematical Techniques for Computer Science
Date: Wednesday 1st June 2016
Time: 09:45 - 11:45
Please answer all THREE Questions.
Use a SEPARATE answerbook for each SECTION.
This is a CLOSED book examination
The use of electronic calculators is permitted provided they
are not programmable and do not store text
[PTO]
, COMP11120
Section A
1. a) Prove the following statement by induction: (4 marks)
n n(n + 1) 2
∑ i3 = 2
.
i=0
b) Recall the recursively defined notion of a list over a set S, and the length function
on such lists given by
Base case len. len [ ] = 0
Step case len. len(s : l) = 1 + len l.
i) Give a recursive definition for a function rpt that takes as input a list over Z
and returns another such list, where each element of the list is repeated. The
expected output of this function for the list [2, 1, 3], for example, is
(3 marks)
[2, 2, 1, 1, 3, 3].
ii) In the notes there is a Java class List which is the direct counterpart of a
recursively defined list. For this class give a method that implements the
function described in part (i) by filling in the two return cases in the following
Java program. (3 marks)
public static List rpt (List l)
{
if (l == null)
return
else
return
}
iii) Prove by induction that for all lists l over S we have (5 marks)
len(rpt l) = 2 len l.
c) Show by induction that for all n ∈ N, (5 marks)
8n − 3n is divisible by 5.
Page 2 of 6