2AC3 W23 Midterm2

You might also like

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

COMPSCI 2AC3 First Name:

Instructor: Hassan Ashtiani


Midterm Exam II Last Name:
March 2023
Student Number

Note that

• The time limit is 45 minutes.

• This examination paper includes 6 pages (including this cover page and the last blank
page) and 4 questions. You are responsible for ensuring that your copy of the papers
is complete. Bring any discrepancy to the attention of your invigilator.

• Total of points is 100 .

Special Instructions:

1. You are not allowed to bring additional resources (notes, books, etc.) to the exam.
You will not need a calculator either.

2. If you need more space, you can use the back of the papers to write your solutions.

3. If you think there is an issue with one of the questions or something is unclear, then
make an assumption based on your judgement and include it in your solution.

Grade Table
Question Points Score
1 30
2 25
3 20
4 25
Total: 100

Page 1 of 6
Student Name: Student Number:

1. (30 points) Which of the following languages are regular and which are not? Check
write “REGULAR” or “NOT REGULAR” beside each choice.

Qn
⃝ {an! | n ≥ 1} where n! = i=1 i

⃝ {x ∈ {a, b}∗ | x = rev(x)} where rev(x) is a string where we have reveresd the
order of symbols in x. For example rev(abb) = bba and rev(abaabbaaabbb) =
bbbaaabbaaba.

⃝ {ak bp cl | k, p, l > 0 and k + p + l is even}

⃝ {x ∈ {a, b}∗ | #a(x) = #b(x)}

⃝ {x ∈ {a, b}∗ | #a(x) + #b(x) = 10}

⃝ {x ∈ {a, b}∗ | x contains the substring abb}

Page 2 of 6
Student Name: Student Number:

2. (25 points) Consider the following DFA. Design a new DFA for the same language but
with the minimum number of states. Show your work (DFA minimization steps).

Page 3 of 6
Student Name: Student Number:

3. (20 points) Design a context-free grammar for the following language (you don’t need
to prove the correctness of your answer).

A = {an cm dm bn | m, n ≥ 1}

Page 4 of 6
Student Name: Student Number:

4. (25 points) Design a grammar in Chomsky Normal Form for L(G) − {ε}, where G is the
grammar defined as follows (I recommend that you show your work to get partial marks
in case your final answer is incorrect)

S → aSbb | A
A → bAbb | S | ε

Page 5 of 6
Student Name: Student Number:

The End

Page 6 of 6

You might also like