Professional Documents
Culture Documents
Marks: 40
Final Exam
Semester: Spring 2020 / 2021
INSTRUCTIONS:
1- Any kind of cheating will subject the student to the penalties specified by the University rules
2- Use of cell phone is strictly prohibited
3- One A4 Cheat Sheet ‘Handwritten’ Is Allowed
Signature: …………………………….……………….……………….…..….…….
Total 40
1/9
Question 1: Short Answer (6 points):
I. True or False:
--------------------------------------------------------------------------------------
------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
II. Write Y or N in the entries of the table below to indicate which classes of
languages are closed under which operations.
III. You are given the transition functions δ of a DFA & NFA.
• DFA, δ : Q × Σ → Q, where Q is the set of states and Σ is the alphabet.
• NFA, δ : Q × Σε → P(Q), where Σε = Σ ∪ {ε} and P(Q) is the power set of Q
• PDA, δ :
• TM, δ :
• Non-deterministic TM, δ :
2/9
Question 2: CFLs/CFGs (4 points):
S a|YZ
Z ZY | a
Y b | ZZ | YY
3/9
Question III (6 points).
a. Show that EP is not regular using the pumping lemma for regular languages
b. Using closure properties, and given that E is regular, together with the result of part (a)
above, argue that P is not regular
c. Show that EP is a context free language by giving a context free grammar that generates
it
4/9
Question IV (4 points).
Let = {0,1,#} & Consider the language A = { 0n#u | |𝑢| = n, n 0}
a. Show that A is context free by giving the state diagram of a PDA that recognizes
A, with as small a number of states as possible
Question V (6 points).
5/9
c) In the following PDA that recognizes A, fill out the missing labels in
the indicated rectangles. Also, complete the following:
We have used the convention that missing arrows are arrows that would have pointed
to qreject , which is also not shown in the diagram.
6/9
a) Show the next 5 configurations in the computations of E, if the input
w=. The starting configuration is given.
q1
Input w M will
7/9
010 Accept Reject Loop
M = “On input w
1. Check if the input starts with a 0 or a 1, and mark the start with
2. If the start character was a 0, look for first unmarked 1; if the start
character was 1, look for the first unmarked 0. Mark it with #.
3. Mark the first unmarked character encountered.
4. Zig-zag across the input, skipping over any #’s. Find the first
unmarked counter character, and mark it.
5. If all the symbols have been marked, accept; otherwise, reject.”
8/9
b. Use the closure properties & another language you should define to prove
that the complement of L is context free.
BONUS (3 points)
Give a high-level description of the Turing machines that decides the following
language
L={0n1n2n | n ≥ 0}
9/9