NPTEL TOC Week 6 Solution
NPTEL TOC Week 6 Solution
L1 = {an bn am | n, m ≥ 0}
L2 = {an bm an | n, m ≥ 0}
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