Mathematical Expression and Reasoning for Computer Science
CSCA 165

Fall 2014
Fall 2013
Term Test 2 / L0101 Solutions
Question 1.
CSC 165 H1
[8 marks]
Part (a) [2 marks]
m is the largest element in S (m S) ( n S, n
m)
Part (b) [2 marks]
(165)7 = 1 (7)2 + 6 (7)1 + 5 (7)0
= 49 42 + 5
12
= 12
Part (c) [2 marks]
After noting that (7)0
Mathematical Expression and Reasoning for Computer Science
CSCA 165

Fall 2014
CSC 165 H1S
Winter 2014
Tutorial # 5 Sample Solutions
Prove or disprove each of the following statements. Write detailed proof structures and justify your work.
1. For all real numbers r, s, if r and s are both positive, then r + s = r + s.
First, write t
Mathematical Expression and Reasoning for Computer Science
CSCA 165

Fall 2014
CSC 165 H1S
Tutorial # 2 Sample Solutions
Winter 2014
As in Tutorial 1, suppose that you are given seven dierent programs T, U, V, W, X, Y, Z, each meant to solve the
same task, where programs T, V, X are written in Java and programs U, W, Y, Z are writte
Mathematical Expression and Reasoning for Computer Science
CSCA 165

Fall 2014
CSC 165 H1S
Winter 2014
Tutorial # 3 Sample Solutions
1. For each equivalence below, either provide a derivation from one side of the equivalence to the other (justify
each step of your derivation with a brief explanation for example, by naming one of the
Mathematical Expression and Reasoning for Computer Science
CSCA 165

Fall 2014
CSC 165 H1S
Tutorial # 6 Sample Solutions
Winter 2014
Recall that a precondition is a condition that is assumed to be true before a set of instructions are executed,
a postcondition is a condition that is assumed to be true after a set of instructions hav
Mathematical Expression and Reasoning for Computer Science
CSCA 165

Fall 2014
CSC 165 H1S
Winter 2014
Tutorial # 9 Sample Solutions
1. Prove or disprove that the set S1 = cfw_(a, b) : a N, b N is countable.
(This is basically just a review of the argument used to show that Q is countable, which was done
in class.)
Intuitively, each
Mathematical Expression and Reasoning for Computer Science
CSCA 165

Fall 2014
CSC 165 H1S
Tutorial # 8 Sample Solutions
Winter 2014
1. Find a tight bound on the worstcase running time of the following algorithm.
1.
2.
3.
4.
5.
6.
7.
8.
# Precondition: L is a list that contains n > 0 real numbers.
max 0
for i 0, 1, . . . , n 1:
for
Mathematical Expression and Reasoning for Computer Science
CSCA 165

Fall 2014
CSC 165 H1F
Tutorial # 1 Sample Solutions
Winter 2014
You are given seven dierent programs with names T, U, V, W, X, Y, Z. Each program attempts to solve the same
task. Programs T, V, X are written in Java, while programs U, W, Y, Z are written in Python
Mathematical Expression and Reasoning for Computer Science
CSCA 165

Fall 2014
CSC 165 H1S
Winter 2014
Tutorial # 7 Sample Solutions
1. Write a detailed structured proof that 5n4 3n2 + 1
is
O(6n5 4n3 + 2n).
Proof outline: By denition of O, we have to show
c R+ , B N, n N, n
B 5n4 3n2 + 1
c(6n5 4n3 + 2n).
This can be done using the f
Mathematical Expression and Reasoning for Computer Science
CSCA 165

Fall 2014
Fall 2013
CSC 165 H1
Term Test 2 / L0101
Duration: 60 minutes (7:15pm 8:15pm)
Aids Allowed: none
Student Number:
Family Name(s):
Given Name(s):
Do not turn this page until you have received the signal to start.
In the meantime, please ll out the identicat
Mathematical Expression and Reasoning for Computer Science
CSCA 165

Fall 2014
CSC 165 H1S
Tutorial # 4 Sample Solutions
Winter 2014
1. Consider the following statement:
If m and n are odd integers, then mn is an odd integer.
(a) Express the statement using logical notation.
m Z, n Z, [(m is odd n is odd) (mn is odd)]
Alternate: m Z