0% found this document useful (0 votes)
43 views3 pages

NPTEL TOC Week 6 Solution

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views3 pages

NPTEL TOC Week 6 Solution

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

NPTEL - Theory of Computation

Total Points 16 Assignment - Week 6 Pages: 3


Question 1 (2 points)
Consider the following languages

L1 = {an bn am | n, m ≥ 0}
L2 = {an bm an | n, m ≥ 0}

Which of the following languages is DCFL?


A. L1
B. L1 ∩ L2
C. L1 ∪ L2
D. L1 ∩ L2
Option A is correct. L1 and L2 are both DCFLs. DCFLs are closed under complementation, but not
under intersection and union.
[L1 ∩ L2 and L1 ∩ L2 are not context-free languages. We can show that these languages do not satisfy
the pumping lemma for context-free languages. On the other hand, L1 ∪ L2 is context-free but not
deterministic context-free. ]
Question 2 (2 points)
Which of the following languages is not necessarily context-free?
A. Complement of a DCFL
B. Intersection of a DCFL and a regular language
C. Union of two DCFLs
D. Intersection of two DCFLs
Option D is correct. DCFLs are closed under complementation and hence the complement of a DCFL
is also DCFL and hence context-free. Intersection of a DCFL and a regular language is also a DCFL
and hence context-free. Since context-free languages are closed under union, therefore the union of two
DCFLs is also context-free. But CFLs as well as DCFLs are not closed under intersection. Therefore
intersection of two DCFLs may not be context-free.
Question 3 (2 points)
Which of the following languages is necessarily deterministic context-free?
A. Complement of a DCFL
B. Intersection of a DCFL and a regular language
C. Union of two DCFLs
D. Intersection of two DCFLs
Both Option A and B are correct. This question will be reevaluated.
DCFLs are not closed under union and intersection but they are closed under complementation and
intersection with a regular language.
Question 4 (2 points)
Let L1 and L2 be two languages such that L1 ⊆ L2 . Consider the following statements.
S1 : If L1 is DCFL then L2 is also DCFL

S2 : If L2 is DCFL then L1 is also DCFL

S3 : Either both L1 and L2 are DCFL or neither L1 nor L2 are DCFL

Which of the following is correct?

Page 1 of 3
A. S1 is true
B. S2 is true
C. S3 is true
D. None of S1 , S2 , S3 is true
Option D is correct. The subset of a DCFL is not necessarily a DCFL. Similarly the superset of a DCFL
is also not necessarily a DCFL. Eg.- the non-context-free language {an bn cn } is a subset of the DCFL
{an bn cm }. Similarly the non-context-free language {an bm cp | m ̸= n ̸= p} is a superset of the DCFL
{an bm | m ̸= n ̸= 0} (considering p = 0).
Question 5 (2 points)
Let L1 be a context-free language, L2 be a DCFL. Which of the following is not true?
A. L1 ∪ L2 is necessarily context-free
B. L1 ∪ L2 is necessarily context-free
C. L1 · L2 is necessarily context-free
D. L1 ∪ L2 is necessarily context-free
Option A is correct. Since DCFLs are closed under complementation, therefore L2 is DCFL (hence,
context-free). Now since context-free languages are closed under union and concatenation, therefore
L1 ∪ L2 , L1 · L, L1 ∪ L2 are all context-free. On the other hand, context-free languages are not closed
under complementation and hence L1 is not necessarily context-free and therefore L1 ∪ L2 is also not
necessarily context-free.

Question 6 (2 points)
Which of the following statements is not true about a deterministic Turing Machine?
A. Equivalent to a nondeterministic Turing Machine in terms of computability
B. Can go to multiple configurations from a given configuration
C. Can have multiple accept configurations
D. Accepts a decidable language
Option B is true. A deterministic Turing Machine can only move to a single configuration at once. (A
non-deterministic Turing Machine can move to multiple configurations at once.)
Question 7 (2 points)
Which of the following is a deterministic context-free language?
A. {wwR | w ∈ {0, 1}∗ and wR is the reverse of w}
B. {ww | w ∈ {0, 1}∗ }
C. {w | w ∈ {0, 1}∗ and w has equal number of 0’s and 1’s}
D. {an bn cm or an bm cn | m, n are natural numbers}
Option C is correct. Option A is the language of all even-length palindromes, which is known to be not
a DCFL. (Refer to section 13.1 in Week 6 Lecture Notes). Option B is not even a context-free language.
(Refer to section 10.2 in Week 5 Lecture Notes). Option D is not a DCFL although it is the union of
two DCFLs (DCFLs are not closed under union.) Option C is a DCFL and here is a DPDA (by final
state) accepting this language.

Page 2 of 3
0, 0 → 00
0, 1 → ϵ
1, 0 → ϵ
1, 1 → 11
ϵ, # → #
ϵ, ϵ → #
start q0 q1 q2
0, # → #0
1, # → #1

The above machine moves to the state q1 whenever the stack gets empty. From state q1 , it pushes a 0/1
(the next input symbol) and moves to state q2 . When in state q2 , the machine pushes the next input
symbol onto the stack if it matches the symbol at the stack top. Otherwise, it pops one symbol out of
the stack. The machine remains in state q2 as long as the stack is not empty and once it gets empty, it
moves to state q1 . q1 is the accept state, that is an input is accepted if and only if at the end of reading
the input, the stack is empty. It is easy to see why this DPDA accepts all (and only those) strings that
have equal number of 0’s and 1’s.

Question 8 (2 points)
Which of the following statements is not true about a Turing Machine?
A. Can move across the work tape in both directions
B. Can write on the work tape
C. Has a fixed (independent of the input) number of states
D. Has a fixed (independent of the input) number of configurations
Option D is correct. The tape contents and how much of the tape is being used by the Turing machine
depends on the input. Hence, the number of possible configurations of a Turing machine is not fixed. It
depends on the input.

Page 3 of 3

You might also like