CSC236, Fall 2012
Assignment 2
Sample solution
1. Odd Maximal Contiguous Ones Free Strings (omcofs) are binary strings that contain no maximal
contiguous substring1 of 1s that is of odd length. For example 0110 is an omcofs because the only
maximal substr
CSC236 fall 2012
regulr expressions
hnny rep
hepdsFtorontoFedu
feRPUH @ehind elevtorsA
http:/www.cdf.toronto.edu/~heap/236/F12/
RITEWUVESVWW
sing sntrodution to the heory of gomputtionD
ghpter U
Outline
regulr expressions
produtD nonEdeterministi pes
regu
CSC236 Fall 2012
Course information sheet
Danny Heap
Here's a summary of the administrative details of CSC236, \Introduction to the theory of computation,"
for Fall 2012. In this course we learn to apply rigour and proof to fundamental tasks of computing.
CSC236, Fall 2012
Assignment 3
sample solution
1. Let L = fx P f0; 1g j fourth-last symbol in x is 0g. Prove that any DFSA that accepts L has at least
16 states. Hint: Consider the sixteen binary strings of length four, and what happens if two of them
dri
4/14/13
www.cdf.tor onto.edu/~ heap/236/F12/Lectur es/W6/g r ading .txt
>Te gt15frlaigaqeto bako syn smtiglk "
hy e / o evn
usin ln r aig oehn ie I
>cno ase ti qeto.
ant nwr hs usin"
>
>Te gt1mr frabs cs (eiyn tebssi srcua
hy e
ak o
ae ae vrfig h ai n tut
Term test 1 | Solutions
CSC 236H1
October 2008
[8 marks]
Question 1.
Prove that for all natural numbers n greater than 1, the set of the rst n positive integers f1; : : : ; ng has
3 2n2 subsets that omit either the element 1, or the element 2, or both the
D
N
H
A
N
D
A
SE
A
H
IN
LE
SE
A
P
LE
IN
P
UNIVERSITY OF TORONTO
Faculty of Arts and Science
Term test #1
CSC 236H1
Duration | 50 minutes
Last Name:
First Name:
Do not turn this page until you have received the signal to start.
(In the meantime, please ll
D
N
H
A
N
D
A
SE
A
H
IN
LE
SE
A
P
LE
IN
P
UNIVERSITY OF TORONTO
Faculty of Arts and Science
Term test #1
CSC 236H1
Duration | 50 minutes
Last Name:
First Name:
Do not turn this page until you have received the signal to start.
(In the meantime, please ll
D
N
H
A
N
D
A
SE
A
H
IN
LE
SE
A
P
LE
IN
P
UNIVERSITY OF TORONTO
Faculty of Arts and Science
Term test #2
CSC 236H1
Duration | 50 minutes
No aids allowed
Last Name:
First Name:
Do not turn this page until you have received the signal to start.
(In the mean
D
N
H
A
N
D
A
SE
A
H
IN
LE
SE
A
P
LE
IN
P
UNIVERSITY OF TORONTO
Faculty of Arts and Science
Term test #2
CSC 236H1
Duration | 50 minutes
Last Name:
First Name:
Do not turn this page until you have received the signal to start.
(In the meantime, please ll
CSC236 tutorial exercises, Week #2
(Best before 11 am, Monday September 24th)
Danny Heap
Here are your tutorial sections:
Surname
Section
Room
TA
Acfw_F
Day 1 (11:00 am)
LM162
Lila
Gcfw_Li
Day 2 (11:00 am)
BA2139
Yuval
Locfw_Si
Day 3 (11:00 am)
BA2145
Ole
CSC236, Fall 2012
Assignment 3
These problems are to give you some practice with correctness proofs, and regular languages. Start early,
and seek out your instructor and teaching assistant when you have questions.
Submit your solutions as a PDF le called
CSC236 fall 2012
regulr expressions
hnny rep
hepdsFtorontoFedu
feRPUH @ehind elevtorsA
http:/www.cdf.toronto.edu/~heap/236/F12/
RITEWUVESVWW
sing sntrodution to the heory of gomputtionD
ghpter U
Outline
regulr expressions
produtD nonEdeterministi pes
regu
CSC236 fall 2012
correct after & before
Danny Heap
[email protected]
BA4270 (behind elevators)
http:/www.cdf.toronto.edu/~heap/236/F12/
416-978-5899
Using Introduction to the Theory of Computation,
Chapter 2
Outline
power
notes
integer power
def power(x
Midterm 1 | Solutions
CSC 236H1 Y
Question 1.
August 2005
[10 marks]
Prove that if the precondition is true when zigzag(int n) starts, then zigzag(int n) terminates.
/*
* Precondition: n is an integer
*/
public static void zigzag(int n) cfw_
int i = 1;
if
CSC236 quiz 5, Tuesday June 21st
Name:
Student number:
Suppose that f and l are integers, that l > f + 1, and that m = b(f + l)=2c (bxc is the greatest integer no
bigger than x, also called the oor of x). Prove that f < m < l (no induction required).
Proo
CSC236 quiz 8, Tuesday July 19
Name:
Student number:
1. Using only logical equivalences (Law of double negation, De Morgan's laws, commutative law, associative law, distributive law, identity law, idempotency law, ! law, $ law), but no truth table, prove
CSC236 quiz 7, Tuesday July 12
Name: Student number:
Prove or disprove the following (no induction needed). 1. If n > 12, then 1 bn=11c dn=11e < n.
Sample solution: The claim is true. Proof: Suppose n > 12. Then n=11 > 1, so (by the de nition of oor) bn=1
CSC236 quiz 6, Tuesday July 5
Name:
Student number:
Consider the method seventeenTicker, below. Prove the following loop invariant holds given the precondition:
P (i) \If there are i iterations of the loop, then 17qi + ri t and ri 16. If there are i + 1 i
CSC236, Fall 2012
Assignment 1
These problems aim to give you some practice writing proofs of facts from dierent domains, using
induction. Unless you nd them easy, you should start working on them early, and be sure to talk them
over with your instructor
CSC236, Fall 2012
Assignment 1
These problems aim to give you some practice writing proofs of facts from dierent domains, using
induction. Unless you nd them easy, you should start working on them early, and be sure to talk them
over with your instructor
CSC236 fall 2012
utomt nd lnguges
hnny rep
hepdsFtorontoFedu
feRPUH @ehind elevtorsA
http:/www.cdf.toronto.edu/~heap/236/F12/
RITEWUVESVWW
sing sntrodution to the heory of gomputtionD
ghpter U
Outline
forml lnguges
pes
notes
some denitions
lphetX niteD no
CSC236, Fall 2012
Assignment 2
These problems are to give you some practice proving facts about recurrences, and the time complexity of
algorithms that are expressed as recurrences. Start early, and seek out your instructor and teaching assistant
when you
CSC236 fall 2012
regular languages, regular expressions
Danny Heap
[email protected]
BA4270 (behind elevators)
http:/www.cdf.toronto.edu/~heap/236/F12/
416-978-5899
Using Introduction to the Theory of Computation,
Chapter 7
Outline
regular expressions,
CSC236 quiz 4, Tuesday June 14th
Name:
Student number:
Recall the language of well-formed arithmetic expressions, E de ned in class as the smallest set such that:
1. x, y , z are in E (this is the basis).
2. If e1 and e2 are in E , then so are (e1 + e2 ),
D
N
H
A
N
D
A
SE
A
H
IN
LE
SE
A
P
LE
IN
P
UNIVERSITY OF TORONTO
Faculty of Arts and Science
Term test #2
CSC 236H1
Duration | 50 minutes
Last Name:
First Name:
Do not turn this page until you have received the signal to start.
(In the meantime, please ll
CSC236 tutorial exercises, Week #2
(Best before 11 am, Monday October 1st)
Danny Heap
Here are your tutorial sections:
Surname
Acfw_F
Gcfw_Li
Locfw_Si
Socfw_Z
Acfw_H
Icfw_M
Ncfw_Z
Section
Day 1 (11:00 am)
Day 2 (11:00 am)
Day 3 (11:00 am)
Day 4 (11:00 am)
CSC236 tutorial exercises #8
(Best before 6 pm, Thursday November 29th)
Danny Heap
Here are your tutorial sections:
Surname
Acfw_F
Gcfw_Li
Locfw_Si
Socfw_Z
Acfw_H
Icfw_M
Ncfw_Z
Section
Day 1 (11:00 am)
Day 2 (11:00 am)
Day 3 (11:00 am)
Day 4 (11:00 am)
Ev
CSC236 fall 2012
Theory of computation
Danny Heap
[email protected]
BA4270 (behind elevators)
Course web page 416-978-5899
Using Introduction to the Theory of Computation, Section
1.2
Outline
Introduction
Chaper 1, Simple induction
Notes
Why reason abou
CSC236 fall 2012
Theory of computation
Danny Heap
[email protected]
BA4270 (behind elevators)
Course web page 416-978-5899
Using Introduction to the Theory of Computation
Outline
Introduction
Chaper 1, Simple induction
Notes
Why reason about computing?