Professional Documents
Culture Documents
COMPSCI120-2021-S1-exam Solutions
COMPSCI120-2021-S1-exam Solutions
COMPSCI120-2021-S1-exam Solutions
SEMESTER 1, 2021
Campus: City
COMPUTER SCIENCE/MATHEMATICS
• This test will begin with 5 minutes of reading time. You may not write anything in
this time.
• There are ?? problems, on pages ?? to ??. The total number of marks is ??. Attempt
all of the questions; there is no penalty for incorrect answers.
• Write all answers in this test booklet; work not written in the test booklet will not be
marked.
• There is more than enough space for an answer to every problem in this booklet. If
you find yourself running out of space, this may be a sign that you are overthinking
things!
• Pages ?? through ?? of this test are left blank, to give you additional paper to work
on.
[1 mark]
Page 1 of ??
COMPSCI 120
[1 mark]
(a) 3 ⊆ X
(b) ∅ ⊆ Y ANSWER
(c) 3 ∈ X ∩ Y
(d) ∅ ∈
/ X ∪Y
[1 mark]
4. Decide which of the following rules defines a function with domain and codomain equal to
R:
1
f (x) is y such that y 3 = 2 .
x
g(x) is y such that y = x3 .
2
(a) Only f.
(b) Only g.
(c) f and g.
(d) f and g are not functions. ANSWER
[1 mark]
Page 2 of ??
COMPSCI 120
Claim: Suppose G is a graph. If there is a circuit C such that C contains every edge of G
exactly once, then the degree of every vertex of G is even.
(a) Assume, that G does not have a circuit C such that C contains every edge of the graph
exactly once.
(b) Assume, that the degree of every vertex in G is odd.
(c) Assume, that there is at least one vertex in G with an odd degree. ANSWER
(d) All the other statements are incorrect
[1 mark]
(a) The algorithm goes through step (3) roughly log3 (n) times. ANSWER
(b) The algorithm outputs 2 on input n = 10.
(c) The algorithm outputs the greatest k, such that n ≥ 3k .
(d) There is at least one input value for which the algorithm never terminates.
[1 mark]
[1 mark]
Page 3 of ??
COMPSCI 120
n! + 1
(a) lim =0
n→∞ n100 + 100000000
n7 log2 (n) + 5n + 1 7
(b) lim 8
=
n→∞ n + 3n + 2 8
(c) The function f (n) = 5n + n4 grows faster than the function g(n) = 2n6 + n3 .
6
(d) The function f (n) = 2n grows faster than the function g(n) = n2000 . ANSWER
[1 mark]
9. A rugby team is posing for a photo after winning the grand final. There are 15 players and
one coach. The photographer needs to arrange them in two rows of 8. The coach, captain
and vice captain must all sit in the front row, and they must sit next to each other in three
adjacent chairs. The other players can sit anywhere.
How many possible ways are there to seat everybody?
(a) 16!
(b) 36 · 13! ANSWER
8! · 13!
(c)
5!
16
(d) 8
[1 mark]
11. Consider the following claim and its proof: there is a prime number p such that p + 2, p + 4
and p + 8 are also prime numbers.
Page 4 of ??
COMPSCI 120
[1 mark]
12. Which of the following statements can be proved using a proof by cases?
(a) If n is a natural number then n2 % 4 is equal to either 0 or 1. ANSWER
√
(b) 2 is irrational.
(c) If G is a graph on at least 2 vertices, then G contains 2 vertices whose degrees are equal.
n(n+1)
(d) The sum of the first n positive integers is 2
.
[1 mark]
Page 5 of ??
COMPSCI 120
Arguments.
There is one argument-based question on this test. You are asked to write a convincing
argument to show that the claim is true. We give out partial credit for good-faith
attempts. As a result, even if you don’t think you have a full and rigorous argument, do
try to explain in your own words what you think is going on! Describe the definitions that
you think are relevant, talk about ideas that you think might lead to the solution
eventually, and otherwise give it your best shot.
13. Consider an alphabet Σ formed using the first five letters of your Student UPI. (Example:
If your Student UPI is abcd123, Σ = {a, b, c, d, 1}. )
Let A be the set of all strings formed using Σ of length at most |Σ|. Assuming you don’t
care about the order in which the strings are chosen, find the number of ways you can choose
three distinct strings from A?
[4 marks]
The solution may vary depending on Σ. This solution is based on the assumption that
Σ has three elements. Say the Student UPI is abcd123, then Σ = {a, b, c, d, 1}.
To calculate |A|, we note that making a string of length k is the same as choosing k from
the set Σ = {a, b, c, d, 1}. Since we care about the order and we allow repetitions, there
are 3k many strings of length k.
That is, |A| = 30 + 31 + 32 + 33 + 34 + 35 = 364.
Now, our task is to choose three strings from 364. But the order in which we choose
them does not matter, and we don’t allow repetitions, there are 364
3
ways in which we
can do this.
In general, if |Σ| = n, then |A| = nk=0 nk
P
52n − 1 = 50 − 1 = 0 = 24 · 0.
0 is a multiple of 24.
Inductive step: Assume that 52k − 1 is a multiple of 24 for integer k ≥ 0. Prove that
52(k+1) − 1 is also a multiple of 24.
Page 6 of ??
COMPSCI 120
52k = 24h + 1
Now
15. Let G be a graph on n vertices (with no loops or multiple edges). Prove that if all vertices
in G have different degrees, then n = 1.
The proof is by contradiction. Suppose that all vertices in G have different degrees
but n ≥ 2. Since G has no multiple edges, the degree of every vertex is ≤ n − 1.
Since all degrees are different, there must be exactly one vertex of degree i for each
i{0, 1, . . . , n − 1}. We can therefore label the vertices as vi for i ∈ {0, 1, . . . , n − 1}, where
vi has degree i. Then vn−1 is adjacent to every other vertex. On the other hand, v0 is
not adjacent to any other vertex, so we have a contradiction. Therefore, n = 1.
[4 marks]
Page 7 of ??