Professional Documents
Culture Documents
Concordia University
COMP 335: Introduction to Theoretical Computer Science
Fall 2015
Assignment 5
Evaluation: 50 pts
(3% of your final grade)
Due date and time: Monday, December 7th 2015 by midnight
Important Note:
Since solutions of this assignment will be posted and discussed with students before the final, no deadline
extension will be granted and no late assignments will be accepted
Question 1 (6 pts)
1. Determine whether or not the following languages are context-free.
a) = { 0, {, } }.
b) = { : 0, 0}.
c) = { {, , } : () = () = 2 ()}.
2. Use the pumping lemma to show that the following languages are not context free
a) = {0 #02 #03 0 }.
b) = {# |w , , {, } }.
Question 2 (4 pts)
a) Determine whether or not the language = { : 2 1} is linear.
b) Consider the language 1 = { : 0, 0}. Show that this language is linear.
Question 3 (4 pts)
Examine the formal definition of a Turing machine to answer the following questions, and explain your
reasoning.
a)
b)
c)
d)
Can a Turing machine ever write the blank symbol on its tape?
Can the tape alphabet be the same as the input alphabet ?
Can a Turing machines head ever be in the same location in two successive steps?
Can a Turing Machine contain just a single state?
Question 4 (4 pts)
Let T be the Turing machine defined by the five tuples: (s0, 0, s1, 1,R), (s0, 1, s1, 0,R), (s0,B, s1, 0,R), (s1, 0,
s2, 1,L), (s1, 1, s1, 0,R), and (s1,B, s2, 0,L). For each of these initial tapes, determine the final tape when T
halts, assuming that T begins in initial position.
COMP335 F2015
Assignment 5_Page 1 of 3
Question 5 (3 pts)
What language is accepted by the Turing Machine whose transition graph is the following:
Question 6 (3 pts)
What does the Turing machine described by the five tuples (s0, 0, s0, 0,R), (s0, 1, s1, 0,R), (s0,B, s2,B,R),
(s1, 0, s1, 0,R), (s1, 1, s0, 1,R), and (s1,B, s2,B,R) do when given
a) 11 as input?
b) an arbitrary bit string as input?
Question 7 (7 pts)
a) Design a Turing machine that accepts the language = {: {, }+ }.
b) Give implementation-level descriptions(pseudocode) of Turing machines that decide the
following language over the alphabet {0,1}
= { |w 0 1}.
Question 8 (6 pts)
1. Construct a Turing machine with tape symbols 0, 1, and B that, when given a bit string as input,
replaces the first 0 with a 1 and does not change any of the other symbols on the tape.
2. Construct a Turing machine that recognizes the set {0 1 2 : 0}
3. Construct a Turing machine that computes the function f (n) = n 3 if n 3 and f (n) = 0 for n =
0, 1, 2 for all nonnegative integers n.
COMP335 F2015
Assignment 5_Page 2 of 3
Question 9 (4 pts)
Say that a write-once Turing machine is a single-tape TM that can alter each tape square at most once
(including the input portion of the tape). Show that this variant Turing machine model is equivalent to the
standard ordinary Turing machine model. (Hint: As first step, consider the case whereby the Turing
machine may alter each tape square at most twice. Use many tape.
Question 10 (9 pts)
1. Which of the following problems is a decision problem?
a) What is the smallest prime greater than n?
b) Is a graph G bipartite?
c) Given a set of strings, is there a finite-state automaton that recognizes this set of strings?
d) Given a checkerboard and a particular game played on it, can this checkerboard game be
represented as search problem using graph?
2. Let be the language containing only one single string w, where
0
.
={
1
Is decidable? Why or why not? For the purposes of this problem, assume that the question of whether a
new renewable energy will be found on earth has an unambiguous Yes or No answer.
Submission:
Note: Assignment not submitted by the due date and in the correct format and/or to the correct
location
will not be graded NO EXCEPTIONS!!!!
o
COMP335 F2015
Assignment 5_Page 3 of 3