April 9 2015 MidTerm

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Midterm Exam: CSC 601 Theory of Computation April 9th, 2015

King Saud University


College of Computer and Information Sciences
Computer Science Department
CSC 601 Theory of Computation

Midterm Exam
April 9th, 2015

Duration: 2 Hours
College and department: CCIS, department of Computer Science
Course Instructor: Prof. Abdelfettah Belghith

Student Name:
Student Number:

Questions Maximum Marks Marks received

1 20=10+10
2 15=5+5+5
3 20=5+5+5+5
4 25=5+10+10
5 20=5+15

Total 100

Instructions:
1. All questions must be answered on this examination paper. You may use both sides
of the answer sheets. There are some extra sheets attached at the end of this
examination paper.
2. This is a closed book exam
3. Please try not to ask questions during the exam. If you find a question to be ambiguous
or unclear, then make and state whatever assumption you feel are necessary, the
correction and mark will be based on the reasonableness of your assumptions
4. Please be precise and answer to the point and do not write everything you know on
the topic. Some marks would be deducted if your answer is not up to the point and
precise.

1
Midterm Exam: CSC 601 Theory of Computation April 9th, 2015

Question 1 (20=10+10)
Consider the Regular Expression R=c*(a+(bc*))* over the alphabet ∑={a, b, c}
1. Using the algorithm to convert a regular expression into a DFA, give the DFA that
accepts L(R). You should explicit the details of your answer.
2. Using the algorithm to convert a regular expression into an NFA, give the NFA that
accepts L(R). You should explicit the details of your answer.

Solutions:

2
Midterm Exam: CSC 601 Theory of Computation April 9th, 2015

3
Midterm Exam: CSC 601 Theory of Computation April 9th, 2015

Question 2 (15=5+5+5)
Prove that the following languages are not regular.
1. L1={w#w: w ϵ {0, 1}*}
2. L2= {w in {a, b}*: w contains more a's than b's}
3. L3={wwR : w in ∑*}
Solutions:

4
Midterm Exam: CSC 601 Theory of Computation April 9th, 2015

Question 3 (20=5+5+5+5)
Consider the alphabet ∑= {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}.
1. Let L1 be the set of decimal representations for nonnegative integers without leading
zeros. Give a regular expression that generates L1
2. Let L2 be the set of nonnegative integers without leading zeros divisible by 2. Give a
regular expression that generates L2
3. Let L3 be the set of nonnegative integers without leading zeros divisible by 3. Give a
DFA that accepts L3
4. Prove that the set of nonnegative integers without leading zeros divisible by 2 or 3 is
regular

Solutions:

5
Midterm Exam: CSC 601 Theory of Computation April 9th, 2015

6
Midterm Exam: CSC 601 Theory of Computation April 9th, 2015

Question 4 (25=5+10+10)
Give a regular expression generating each of the following languages.
1. L1={w in ∑*: w contains the substring ac} where ∑={a, b, c}
2. L2={w in ∑*: w does not contains the substring ac} where ∑={a, b, c}
3. L3={w in ∑*: w contains (3k+1) b's for some k >= 0} where ∑={a, b}
Solutions:

7
Midterm Exam: CSC 601 Theory of Computation April 9th, 2015

Question 5 (20=5+15)
Consider the NFA M=(K, ∑, Δ, s, F) where: K= {q0, q1, q2, q3, q4}, ∑={a, b}, s=q0, F={q4} and
Δ={(q0, ϵ, q1), (q0, b, q2), (q1, a, q0), (q1, ϵ, q2), (q1, ϵ, q3), (q1, a, q4), (q2, b, q4), (q3, a, q4),
(q4, ϵ, q3)}.
1. Portrays the state transition diagram of M. Check that there are indeed the 9 defined
transitions.
2. Apply the subset construction algorithm to obtain an equivalent DFA. Explicit all steps
of the application of the algorithm.
Solutions:

You might also like