Mathematical Expression and Reasoning for Computer Science
CSC 165

Summer 2014
CSC165, Summer 2014
Assignment 2
Weight: 5%
Solutions
The goal of this assignment is to make sure that you understand how to relate language and logic, and
how to transform statements to get their negation, converse, and contrapositive.
You may work in gr
Mathematical Expression and Reasoning for Computer Science
CSC 165

Summer 2014
CSC 165 Midterm Exam Solutions
1 of 5
1. [10] Consider the domain D of all people. Dene the predicates Y(x, y): x is younger than y, H(x): x is a hipster, and
A(x): x loves Apple. Translate each English sentence below into logical notation, and translate
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC 165 H1F
Homework Exercise # 6
Worth: 4%
Fall 2016
Due: By 9:00pm on Wednesday 2 November.
Your submission must be a PDF file named e6.pdf and it must be handedin using the
MarkUs system. You must create the PDF file using a document preparation syste
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC 165 H1F
Worth: 4%
Homework Exercise # 5
Fall 2016
Due: By 9:00pm on Wednesday 26 October.
Your submission must be a PDF file named e5.pdf and it must be handedin using the
MarkUs system. You must create the PDF file using a document preparation syste
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC 165 H1F
Homework Exercise # 8
Worth: 4%
Fall 2016
Due: By 9:00pm on Wednesday 30 November.
Your submission must be a PDF file named e8.pdf and it must be handedin using the
MarkUs system. You must create the PDF file using a document preparation syst
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC 165 H1F
Homework Exercise # 7
Worth: 4%
Fall 2016
Due: By 9:00pm on Friday 11 November.
Your submission must be a PDF file named e7.pdf and it must be handedin using the
MarkUs system. You must create the PDF file using a document preparation system
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC 165 H1F
Homework Exercise # 9
Worth: 4%
Fall 2016
Due: By 9:00pm on Wednesday 7 December.
Your submission must be a PDF file named e9.pdf and it must be handedin using the
MarkUs system. You must create the PDF file using a document preparation syste
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC 165 H1F
Homework Exercise # 4
Worth: 4%
Fall 2016
Due: By 9:00pm on Wednesday 12 October.
Your submission must be a PDF file named e4.pdf and it must be handedin using the
MarkUs system. You must create the PDF file using a document preparation syste
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC 165 H1F
Tutorial Exercises # 9
Fall 2016
1. Consider the insertion sort algorithm that is given in the following python function:
def insertion_sort(A):
" (list of int) > NoneType
Modify the list A so that the elements are in nondecreasing order.
>
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC 165 H1F
Fall 2016
Tutorial Exercises # 6 Sample Solutions
1. (a) Prove
n
X
i2 =
i=1
n(n + 1)(2n + 1)
.
6
n
X
Proof. Let us start by defining the predicate P (n) :
i2 = n(n + 1)(n + 2)/6, where n N+ . We
need to prove that n N+ , P (n).
n
1
X
X
Base c
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC 165 H1F
Tutorial Exercises # 6
1. In lecture, we proved that
n
X
i=1
n
X
i=
Fall 2016
n(n + 1)
. It turns out that you can also show that
2
n(n + 1)(2n + 1)
6
i=1
n
X
n(n + 1) 2
(b)
i3 = 1 + 8 + 27 + . . . + n3 =
2
(a)
i2 = 1 + 4 + 9 + . . . + n2 =
i=
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC 165 H1F
Tutorial Exercises # 7
Fall 2016
Recall that in class we saw the following definition, for functions f, g : N R+ :
g O(f ) c, n0 R+ n N n n0 g(n) c f (n)
Working with this definition, we also have:
g 6 O(f ) c, n0 R+ n N n n0 g(n) > c f (n)
1.
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC165
September 16, 2014
Announcements
Tutorials start this week, exercise posted on course
web page, work on them before tutorial.
Submit slogURL.txt to MarkUs by Friday, include a
paragraph on topics from Week 1~2.
Lecture 2.1 Quantifiers (cont.)
Cou
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC165 Fall 2014
Mathematical Expression and Reasoning
for Computer Science
Section L5101
Larry Zhang
Offices:
BA 5206 (most of the time)
BA 4262 (office hours)
Email: ylzhang@cs.toronto.edu
The teaching team
Instructors:
Danny Heap & Larry Zhang
TAs:
C
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC165 Week 7
Larry Zhang, October 21, 2014
announcements
A1 marks on MarkUs
class average: 83%
remarking form: available at course web page
A2 is out, due on Nov. 3, 10:00pm
manage your time wisely!
(lots of) practice questions with solutions
http
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC165
Mathematical Expression and
Reasoning for Computer Science
Module 9
Proof by Cases
2
Proof by Cases
Prove : ()
Split your argument into differences cases
Prove the conclusion for each case
Sometimes the different cases are implicit
What makes
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC165
Mathematical Expression and
Reasoning for Computer Science
Module 8
Equivalence
2
Equivalence
If is true, and if is true:
if and only if
iff
Notation:
only if :
if :
iff :
Note: :
3
Equivalence
Other sayings of equivalence:
implies
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC165
Mathematical Expression and
Reasoning for Computer Science
Module 7
About Sequences
2
What is a Sequence?
A sequence is an ordered collection of objects
Order of the elements is important
The number of elements is called the length of the sequen
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
Easy 4.0CSC165 Final ReviewPart I
2016.4.8
&
You must achieve at least 40% of the possible marks on the final exam in order to pass
this course.
Review Session
Part I: Logic and Proof, Proof by induction, onetoone/onto functions.
Part II: Set, Asymptot
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
Lecture 8 Code Examples
Lecture 8 Code Examples
1 def print_list (L):
2
Print out each item of a list on separate lines .
3
i = 0
4
while i < len(L):
5
print L[i]
6
i += 1
1 def so_fast (L):
2
3
Print out some basic facts about a list.
4
L contains at le
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC165 Quiz 6
This quiz lasts 10 minutes. Answer the following questions fully. Your goal should not be to get the right answer, but to
convince the marker that you know what youre doing. Each quiz is marked on the following 3point scale:
3: Youve master
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
Some Solutions to Problems for Lecture 6
Instructor: David Liu
3. This one is actually false, and the trick is to use a rapidly decreasing function. Heres what well prove:
f : N R+ , a R+ , c R+ , n N, ( f + a)(n) > c f (n).
Let f (x) = x1 . # Function d
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC165 Quiz 2
This quiz lasts 10 minutes. Answer the following questions fully. Your goal should not be to get the right answer, but to
convince the marker that you know what youre doing. Each quiz is marked on the following 3point scale:
3: Youve master
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
Lecture 10: Complexity Theory Part I Easy Problems
Instructor: David Liu
July 24, 2013
Complexity Theory is the study of problems, and specifically, how hard problems are. Instead of talking about
particular algorithms that solve the same problem, were g
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
Lecture 8: Analysing Running Time of Algorithm Code
Instructor: David Liu
July 10, 2013
Three important questions:
What makes software good?
What computer/cellphone/hardware/human resources does a program use?
What factors affect program running time?
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
University of Toronto, Faculty of Arts and Science
December 2015 EXAMINATIONS
CSC236H1F
Professor Azadeh Farzan
Seyed Amir Hejazi
(December 15, 2015: 9am12pm)
Duration: 3 hours
Name:
Student Number:
Lecture Session (circle one):
_ Morning Afternoon _ Eve
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
Code:12345
DEPARTMENT OF MATHEMATICS
University of Toronto
MAT 136H1S
Term Test
Wednesday, March 2, 2016
Time allowed: 1 hour, 30 minutes
NAME OF STUDENT:
(Please PRINT full name
and UNDERLINE surname):
STUDENT NUMBER:
SIGNATURE OF STUDENT
(in INK or BALL
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
UNIVERSITY OF TORONTO
. Faculty of Arts and Science
APRIL 2016 EXAMINATIONS
CSG 236H1S
Bahar Aameri
Duration 3 hours
Aids Allowed: One handwritten
Printed,
typed,
Student Number:
8.5x11 doublesided aid sheet.
or photocopied
sheets
are not
allowed.
Last
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
CSC165 Tutorial #1
Exercises
Winter 2015
Work on these exercises before the tutorial. You dont have to come up with a complete solution, but you
should be prepared to discuss them with your TA.
Here are two statements, S1 and S2
S1: All pernicious humans
Mathematical Expression and Reasoning for Computer Science
CSC 165

Spring 2015
Dunbar 24? Queow 3 E'h
MJHHM: vegcfw_Kr .Lgale" [View Iijefjt ; Hrgltraf ) fwzj cfw_mg2]
f fLJ'+m .
F : 14 Lap. 0' '21
if m M TM M"
M new W"?
m Va "WW
,4qu [Tgh
Tim lrjilewglv
TM Myth3] an]? R =3
1101 Wyn? 7" 9 # 59mg waft) Hf. 13m?
Tim My] 73,
TM H