2023 question paper

FORMAL LANGUAGE & AUTOMATA THEORY

28 questions

  1. Q1a. A language accepted by deterministic pushdown automata is closed under which of the following? (i) Complement (ii) Union (iii) Both (i) and (ii) (iv) None of the above20232m

    Module 2: Context-Free Languages (CFL) and PDA

    A language accepted by deterministic pushdown automata is closed under which of the following?

    (i) Complement
    (ii) Union
    (iii) Both (i) and (ii)
    (iv) None of the above

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (i) Complement

    Explanation

    Languages accepted by Deterministic Pushdown Automata (DPDA) are Deterministic Context-Free Languages (DCFLs).

    Closure Properties of DCFLs

    Operation Closed?
    Complement Yes
    Union No
    Intersection No
    Intersection with Regular Yes
    Concatenation No
    Kleene Star No

    Reason:

    • A DPDA can be complemented by swapping final/non-final states after ensuring it is total and handles end-of-input deterministically, similar to DFA complementation, but adapted for stack handling.
    • DCFLs are not closed under union: e.g., L1={anbn∣n≥0}L_1 = \{a^n b^n \mid n\ge0\} and L2={anb2n∣n≥0}L_2 = \{a^n b^{2n} \mid n\ge0\} are DCFLs, but L1∪L2L_1 \cup L_2 is not a DCFL.
    • Since union fails, (iii) Both is false and (iv) is false.

    Contrast with general CFLs (NPDA)

    CFLs (non-deterministic) are not closed under complement nor intersection, but are closed under union, concatenation, Kleene star – opposite behaviour.

    Final Answer

    DCFL is closed under complement only. Hence option (i) Complement is correct.

  2. Q1b. Let N be an NFA with n states and let M be the minimized DFA with m states recognizing the same language. Which of the following is necessarily true? (i) m \le 2^n (ii) n \le m (iii) M has one accept state (iv) m = 2^n20232m

    Module 1: Introduction & Regular Languages

    Let NN be an NFA with nn states and let MM be the minimized DFA with mm states recognizing the same language. Which of the following is necessarily true?

    (i) m≤2nm \le 2^n
    (ii) n≤mn \le m
    (iii) MM has one accept state
    (iv) m=2nm = 2^n

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (i) m≤2nm \le 2^{n}

    Explanation

    NFA → DFA subset construction:

    • Each DFA state corresponds to a subset of NFA states.
    • With nn NFA states, there are at most 2n2^{n} subsets.
    • Hence the DFA obtained (before minimization) has ≤2n\le 2^{n} states.
    • Minimized DFA MM has m≤m \le number of subset-construction DFA states ≤2n\le 2^{n}.

    So (i) is always true.

    Other options:

    • (ii) n≤mn \le m is false: NFA can be exponentially smaller (e.g., language of nthn^{th} from end needs n+1n+1 NFA states but 2n2^{n} DFA states → n<mn < m sometimes, but not necessarily; sometimes DFA is smaller).
    • The converse m≥nm \ge n is not guaranteed.

    Final Answer

    m≤2nm \le 2^{n} → Option (i). (Minimized DFA minimal, so mm is even tighter, but certainly ≤2n\le 2^{n}.)

  3. Q1c. A minimum state deterministic FA accepting the language: L = \{ w \mid w \in \{0,1\}^* \} where the number of 0's and 1's in w are divisible by 3 and 5 respectively, has: (i) 15 states (ii) 11 states (iii) 10 states (iv) 9 states20232m

    Module 1: Introduction & Regular Languages

    A minimum state deterministic FA accepting the language:

    L={w∣w∈{0,1}∗}L = \{ w \mid w \in \{0,1\}^* \}

    where the number of 0's and 1's in ww are divisible by 3 and 5 respectively, has:

    (i) 15 states
    (ii) 11 states
    (iii) 10 states
    (iv) 9 states

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (i) 15 states (Other options typically include 8, etc., correct is 15)

    Explanation

    Language L={w∈{0,1}∗∣#0(w) mod 3=0  ∧  #1(w) mod 5=0}L = \{ w \in \{0,1\}^* \mid \#_0(w) \bmod 3 =0 \;\land\; \#_1(w) \bmod 5 =0 \}.

    This is intersection of two regular languages:

    • L0={w∣#0(w)≡0(mod3)}L_0 = \{ w \mid \#_0(w) \equiv 0 \pmod 3 \} → DFA with 3 states (r0=0,1,2r_0=0,1,2).
    • L1={w∣#1(w)≡0(mod5)}L_1 = \{ w \mid \#_1(w) \equiv 0 \pmod 5 \} → DFA with 5 states (s0=0..4s_0=0..4).

    Intersection via product construction: states = Q0×Q1Q_0 \times Q_1 → 3×5=153 \times 5 =15 states.

    Transitions: δ((r,s),0)=((r+1) mod 3,s)\delta((r,s),0) = ((r+1)\bmod 3, s), δ((r,s),1)=(r,(s+1) mod 5)\delta((r,s),1) = (r, (s+1)\bmod5).

    Initial (0,0)(0,0), accepting (0,0)(0,0) only. Minimal because all pairs distinguishable (Myhill-Nerode: $(i,j)
    ot\equiv (i',j')if if i
    eq i'or or j
    eq j'$).

    Final Answer

    15 states (product DFA, minimal).

  4. Q1d. The language \{ a^n b^n c^{n+m} \mid m, n \ge 1 \} is: (i) regular (ii) context-free but not regular (iii) context-sensitive but not context-free (iv) type 0 but not context-sensitive20232m

    Module 3: Context-Sensitive Languages

    The language {anbncn+m∣m,n≥1}\{ a^n b^n c^{n+m} \mid m, n \ge 1 \} is:

    (i) regular
    (ii) context-free but not regular
    (iii) context-sensitive but not context-free
    (iv) type 0 but not context-sensitive

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (iii) Context-sensitive but not context-free (and hence not regular)

    Explanation

    L={anbncn+m∣m,n≥1}={anbnck∣k=n+m>n}L = \{ a^n b^n c^{n+m} \mid m,n \ge 1 \} = \{ a^n b^n c^{k} \mid k = n+m > n \}.

    Not Context-Free

    Assume LL is CFL, let pp be pumping length. Take w=apbpcp+1∈Lw = a^p b^p c^{p+1} \in L (n=p,m=1n=p, m=1). By pumping lemma for CFL, w=uvxyzw = uvxyz with ∣vxy∣≤p|vxy|\le p, ∣vy∣>0|vy|>0. Pumping must stay within first pp aa's or bb's or cc's. Any pumping changes counts and breaks condition #c>#a=#b \#_c > \#_a = \#_b (or breaks anbna^n b^n). Formal proof shows LL not CFL. Equivalent to anbncna^n b^n c^n (which is not CFL) with extra cmc^m tail; intersection with regular a∗b∗c∗a^*b^*c^* does not help but L∩a∗b∗cpL \cap a^*b^*c^p style shows non-CFL.

    Context-Sensitive

    It is accepted by Linear Bounded Automaton. Grammar is context-sensitive:

    S→aSBC∣aBCS \rightarrow a S B C \mid a B C
    CB→BCCB \rightarrow BC
    aB→aba B \rightarrow a b
    bB→bbb B \rightarrow b b
    bC→bcb C \rightarrow b c
    cC→ccc C \rightarrow c c

    This is Type-1 (CSG) but not Type-2. It is decidable but not CFL.

    Final Answer

    CSL but not CFL → Option (iii). Also not regular; ultimately Type-1 in Chomsky hierarchy.

  5. Q1e. The string 1101 does not belong to the set represented by: (i) 1^* 0^* (0+1) (ii) 1(0+1)^*101 (iii) (1(0)^*(0+1)^*(0+1))^* (iv) \{00 + (11)^*0\}^*20232m

    Module 1: Introduction & Regular Languages

    The string 11011101 does not belong to the set represented by:

    (i) 1∗0∗(0+1)1^* 0^* (0+1)
    (ii) 1(0+1)∗1011(0+1)^*101
    (iii) (1(0)∗(0+1)∗(0+1))∗(1(0)^*(0+1)^*(0+1))^*
    (iv) {00+(11)∗0}∗\{00 + (11)^*0\}^*

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (iv) {00+(11)∗0}∗\{00 + (11)^*0\}^*

    Explanation

    Test w=1101w=1101 against each regex:

    (i) 1∗0∗(0+1)1^*0^*(0+1): = 1∗1^* then 0∗0^* then single 00 or 11. 1101=11⏟1∗0⏟0∗1⏟(0+1)1101 = \underbrace{11}_{1^*} \underbrace{0}_{0^*} \underbrace{1}_{(0+1)} → belongs.

    (ii) 1(0+1)∗1011(0+1)^*101: Must start with 11 and end with 101101. 1101=11⏟(0+1)∗1011101 = 1 \underbrace{1}_{(0+1)^*}101? Actually 11011101 = 11 + ϵ\epsilon + 101101 with middle 11? 1(0+1)∗101=1 x 1011(0+1)^*101 = 1\,x\,101 where x=0x=0? For w=1101w=1101, x=0x=0? Wait 1+0+101=11011+0+101 =1101 exactly, so w=1⋅0⋅101w = 1\cdot0\cdot101? No 1⋅101=11011\cdot101 =1101 with x=ϵx=\epsilon? 1(0+1)∗=11(0+1)^* =1, remaining 101=101101 =101 → 11011101 → belongs.

    (iii) (1(0)∗(0+1)∗(0+1))∗(1(0)^*(0+1)^*(0+1))^*: This is essentially Σ∗\Sigma^* variant (can generate any string) → belongs.

    (iv) {00+(11)∗0}∗\{00 + (11)^*0\}^*: Generators: 0000 (ends 0) and (11)∗0(11)^*0 = even 1's followed by 0, also ends 0. Any concatenation of blocks ending in 0 always ends in 0. 11011101 ends in 1 → does not belong.

    Final Answer

    $1101
    otin {00 + (11)^0}^$ → Option (iv).

  6. Q1f. A given grammar is called ambiguous if: (i) two or more productions have the same non-terminal on LHS (ii) a derivation tree has more than one associated sentence (iii) there exists a sentence with more than one derivation tree (iv) brackets are not present in the grammar20232m

    Module 2: Context-Free Languages (CFL) and PDA

    A given grammar is called ambiguous if:

    (i) two or more productions have the same non-terminal on LHS
    (ii) a derivation tree has more than one associated sentence
    (iii) there exists a sentence with more than one derivation tree
    (iv) brackets are not present in the grammar

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (iii) there exists a sentence with more than one derivation tree

    Explanation

    Ambiguous Grammar: Grammar GG is ambiguous iff there exists a string w∈L(G)w \in L(G) that has two or more distinct derivation trees (or equivalently two distinct leftmost / rightmost derivations).

    • (i) “two productions have same LHS” → false; e.g., S→a∣bS \rightarrow a \mid b has same LHS but not ambiguous (each string one tree).
    • (ii) “derivation tree has more than one sentence” — every tree yields exactly one sentence (its yield), false.
    • (iii) True — definition of ambiguity: ∃w:∣{parse trees for w}∣≥2\exists w: |\{ \text{parse trees for }w\}| \ge 2.
    • (iv) “brackets not present” — irrelevant.

    Example ambiguous: S→S+S∣S∗S∣aS \rightarrow S+S \mid S*S \mid a; string a+a∗aa+a*a has two trees (different precedence).

    Final Answer

    Ambiguous iff some sentence has ≥2 parse trees → Option (iii).

  7. Q1g. Which one of the following statements is true? (i) The intersection of two CFLs is context-free (ii) Every CFL can be accepted by a DPDA (iii) The union of two CFLs is context-free (iv) The complement of a CFL is context-free20232m

    Module 2: Context-Free Languages (CFL) and PDA

    Which one of the following statements is true?

    (i) The intersection of two CFLs is context-free
    (ii) Every CFL can be accepted by a DPDA
    (iii) The union of two CFLs is context-free
    (iv) The complement of a CFL is context-free

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (iii) The union of two CFLs is context-free

    Explanation

    CFL closure:

    Operation Closed? Example
    Union L1∪L2L_1 \cup L_2 Yes S→S1∣S2S \rightarrow S_1 \mid S_2
    Intersection L1∩L2L_1 \cap L_2 No anbnc∗∩a∗bncn=anbncna^n b^n c^* \cap a^* b^n c^n = a^n b^n c^n not CFL
    Complement No Follows from De Morgan
    Every CFL is DPDA No {anbn}∪{anb2n}\{a^n b^n\} \cup \{a^n b^{2n}\} is CFL but not DCFL
    Intersection of 2 CFLs is CFL No

    Thus only union is guaranteed.

    Options:

    • (i) Intersection → false
    • (ii) Every CFL is DPDA → false (DCFL ⊂ CFL)
    • (iii) Union → true ✓
    • (iv) Complement → false

    Final Answer

    Union of two CFLs is CFL → Option (iii).

  8. Q1h. From the options, the pair having different expressive powers is: (i) DPDA and NPDA (ii) DFA and NFA (iii) single-tape TM and multi-tape TM (iv) deterministic single-tape TM and nondeterministic single-tape TM20232m

    Module 4: Turing Machines (TM)

    From the options, the pair having different expressive powers is:

    (i) DPDA and NPDA
    (ii) DFA and NFA
    (iii) single-tape TM and multi-tape TM
    (iv) deterministic single-tape TM and nondeterministic single-tape TM

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (i) DPDA and NPDA

    Explanation

    Expressive power comparison:

    Pair Power Same?
    DPDA vs NPDA Different — NPDA = CFL, DPDA = DCFL ⊂ CFL. Example {anbn}∪{anb2n}\{a^n b^n\}\cup\{a^n b^{2n}\} is CFL but not DCFL.
    DFA vs NFA Same — both = Regular
    Single-tape TM vs Multi-tape TM Same — both = RE, polytime difference only
    Deterministic single-tape TM vs Nondeterministic single-tape TM Same — DTM=NTMDTM = NTM in power

    Hence different expressive powers is DPDA vs NPDA.

    Final Answer

    DPDA and NPDA have different power → Option (i).

  9. Q1i. Recursive languages are: (i) a proper superset of CFLs (ii) always recognizable (iii) also called type-0 languages (iv) recognizable by Turing machines20232m

    Module 4: Turing Machines (TM)

    Recursive languages are:

    (i) a proper superset of CFLs
    (ii) always recognizable
    (iii) also called type-0 languages
    (iv) recognizable by Turing machines

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (i) a proper superset of CFLs (and (ii)/(iv) also true depending on option set)

    Explanation

    Recursive languages = Decidable languages = LL decided by TM that always halts.

    Hierarchy:
    Regular⊂DCFL⊂CFL⊂CSL⊂Recursive⊂RE \text{Regular} \subset \text{DCFL} \subset \text{CFL} \subset \text{CSL} \subset \text{Recursive} \subset \text{RE}

    • (i) Proper superset of CFLs → True. Every CFL is recursive (PDA can be simulated by halting TM), but not vice versa (e.g., anbncna^n b^n c^n is recursive not CFL).
    • (ii) Always recognizable (RE) → True, recursive ⊂ RE, so yes.
    • (iv) Recognizable by TM → True (RE definition).
    • (iii) also called Type-0 → False, Type-0 = RE, not Recursive (Type-1 is CSL, not Recursive either; Recursive is not a Chomsky type but decidable).

    If single choice, (i) proper superset of CFLs is the intended answer. If multiple, (i),(ii),(iv) are true.

    Final Answer

    Recursive languages are proper superset of CFLs → Option (i) (also RE).

  10. Q1j. If P and Q are regular expressions (P is not null), then R = Q + RP has the unique solution: (i) R = QP (ii) R = PQ^* (iii) R = QP^* (iv) R = QP^*20232m

    Module 1: Introduction & Regular Languages

    If PP and QQ are regular expressions (PP is not null), then R=Q+RPR = Q + RP has the unique solution:

    (i) R=QPR = QP
    (ii) R=PQ∗R = PQ^*
    (iii) R=QP∗R = QP^*
    (iv) R=QP∗R = QP^*

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (iii) R=QP∗R = QP^* (Arden’s Theorem)

    Explanation

    Arden’s Theorem: If PP does not contain ϵ\epsilon, then equation R=Q+RPR = Q + RP has unique solution R=QP∗R = QP^*.

    Proof: R=Q+(Q+RP)P=Q(ϵ+P)+RP2=⋯=Q(ϵ+P+P2+⋯+Pk)+RPk+1R = Q + (Q + RP)P = Q(\epsilon + P) + RP^2 = \dots = Q(\epsilon + P + P^2 + \dots + P^{k}) + RP^{k+1}. As k→∞k \to \infty, RPk+1RP^{k+1} contributes no finite strings if language, so R=QP∗R = QP^*.

    • (i) QPQP missing star → incomplete.
    • (ii) PQ∗PQ^* swaps order (concatenation not commutative).
    • (iv) duplicate of (iii).

    Condition: PP not null ($\epsilon
    otin P$) ensures uniqueness.

    Final Answer

    R=QP∗R = QP^* → Option (iii) (also (iv) if duplicate).

  11. Budget App•POCKETLY

    Pocketly on Android

    Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.

    Install Pocketly
  12. Q2a. Discuss the Chomsky hierarchy of grammars with suitable examples.20237m

    Module 1: Introduction & Regular Languages

    Discuss the Chomsky hierarchy of grammars with suitable examples.

    View this question on its own page →
  13. Q2b. State the pumping lemma for context-free languages.20237m

    Module 2: Context-Free Languages (CFL) and PDA

    State the pumping lemma for context-free languages.

    View this question on its own page →
    Worked Solution

    Answer

    Pumping Lemma for Context-Free Languages (CFL)

    Statement:
    Let LL be a context-free language. Then there exists a constant p≥1p \ge 1 (the pumping length) such that for every string w∈Lw \in L with ∣w∣≥p|w| \ge p, ww can be written as

    w=uvxyz w = uvxyz

    satisfying the following conditions:

    1. ∣vxy∣≤p|vxy| \le p — the middle part vxyvxy is short (bounded by pp)
    2. ∣vy∣≥1|vy| \ge 1 — at least one of vv or yy is non-empty (not both empty)
    3. For all i≥0i \ge 0: uvixyiz∈Luv^i x y^i z \in L — pumping vv and yy together (0, 1, 2, … times) keeps the string in LL

    Interpretation

    • For any sufficiently long CFL string, you can find a decomposition into 5 parts such that the inner vv and yy can be "pumped" simultaneously (repeated same number of times) and the result stays in the language.
    • The simultaneous pumping of vv and yy is the key difference from the regular pumping lemma (which pumps a single yy).
    • ∣vxy∣≤p|vxy| \le p means the "pumpable" region is near the center of the string (within length pp).

    How to Use (Proving Non-CFL)

    To prove LL is not context-free:

    1. Assume LL is CFL → pumping lemma holds with some pp.
    2. Choose a specific string w∈Lw \in L with ∣w∣≥p|w| \ge p (usually w=apbpcpw = a^p b^p c^p or similar).
    3. Show that for every valid decomposition w=uvxyzw = uvxyz satisfying (1) and (2), there exists some ii such that $uv^i x y^i z
      otin L$.
    4. Contradiction → LL not CFL.

    Common Strategy: Choose ww so that any vxyvxy of length ≤p\le p cannot span all "coordinated" parts (e.g., three blocks apbpcpa^p b^p c^p). Pumping disrupts the balance.


    Example Application

    Prove L={anbncn∣n≥0}L = \{a^n b^n c^n \mid n \ge 0\} is not CFL.

    1. Let pp be pumping length. Take w=apbpcp∈Lw = a^p b^p c^p \in L, ∣w∣=3p≥p|w| = 3p \ge p.
    2. By lemma, w=uvxyzw = uvxyz with ∣vxy∣≤p|vxy| \le p, ∣vy∣≥1|vy| \ge 1.
    3. Since ∣vxy∣≤p|vxy| \le p, the substring vxyvxy cannot contain aa's, bb's, and cc's simultaneously — it lies within at most two adjacent blocks.
    4. Cases:
      • vxyvxy only in aa's: pumping adds aa's → $#a
        eq #b = #c$ ❌
      • vxyvxy only in bb's: pumping adds bb's → $#b
        eq #a, #c$ ❌
      • vxyvxy only in cc's: pumping adds cc's ❌
      • vxyvxy spans apbpa^p b^p boundary: pumping changes #a\#a and #b\#b differently (or adds both) → $#a
        eq #bor or #b
        eq #c$ ❌
      • vxyvxy spans bpcpb^p c^p boundary: similar ❌
    5. All decompositions fail for some $i
      e 1$. Contradiction.

    Contrast with Regular Pumping Lemma

    Aspect Regular (Type-3) CFL (Type-2)
    String split w=xyzw = xyz w=uvxyzw = uvxyz
    Pumped part yy (single) vv and yy (pair)
    Constraint ∣xy∣≤p|xy| \le p ∣vxy∣≤p|vxy| \le p
    Non-empty ∣y∣≥1|y| \ge 1 ∣vy∣≥1|vy| \ge 1
    Result xyiz∈Lxy^i z \in L uvixyiz∈Luv^i x y^i z \in L

    Important Notes

    • The lemma gives necessary but not sufficient condition for CFL.
    • There are non-CFL languages that satisfy the lemma (e.g., some non-context-free languages still pump).
    • For CFL, pumping is simultaneous of two substrings (vv and yy), reflecting stack push/pop pairing.
    • The pumping length pp depends on the grammar (e.g., number of variables in Chomsky Normal Form).

    Final Answer

    Pumping Lemma for CFL: ∃p≥1\exists p \ge 1 such that ∀w∈L,∣w∣≥p\forall w \in L, |w| \ge p, w=uvxyzw = uvxyz with ∣vxy∣≤p|vxy| \le p, ∣vy∣≥1|vy| \ge 1, and ∀i≥0,uvixyiz∈L\forall i \ge 0, uv^i x y^i z \in L. Used to prove languages like {anbncn}\{a^n b^n c^n\} are not context-free.

  14. Q3a. Design a PDA (empty stack and final state both) for L = \{ WW^r \mid W \in \{a,b\}^* \}.20237m

    Module 2: Context-Free Languages (CFL) and PDA

    Design a PDA (empty stack and final state both) for L={WWr∣W∈{a,b}∗}L = \{ WW^r \mid W \in \{a,b\}^* \}.

    View this question on its own page →
    Worked Solution

    Answer

    Language: L={WWr∣W∈{a,b}∗}L = \{ W W^r \mid W \in \{a,b\}^* \} — even-length palindromes over {a,b}\{a,b\}.

    WrW^r = reverse of WW. Examples: ϵ\epsilon, aaaa, bbbb, abbaabba, baabbaab, aabbaaaabbaa, …


    PDA Design (NPDA)

    This language is not deterministic (NPDA needed) — the PDA must guess the midpoint.

    PDA: P=(Q,Σ,Γ,δ,q0,Z0,F)P = (Q, \Sigma, \Gamma, \delta, q_0, Z_0, F)

    • Q={q0,q1,q2}Q = \{q_0, q_1, q_2\}
      • q0q_0: reading first half, pushing symbols
      • q1q_1: reading second half, popping & matching
      • q2q_2: accept (final state)
    • Σ={a,b}\Sigma = \{a, b\}
    • Γ={a,b,Z0}\Gamma = \{a, b, Z_0\} (Z0Z_0 = bottom marker)
    • q0q_0 = start
    • F={q2}F = \{q_2\} (final state)
    • Empty stack also accepted: Z0Z_0 remains at bottom, all input symbols pushed then popped

    Transition Function δ\delta

    Current State Input Stack Top Action Next State Push/Pop
    q0q_0 aa X∈{a,b,Z0}X \in \{a,b,Z_0\} Push aa q0q_0 aa
    q0q_0 bb XX Push bb q0q_0 bb
    q0q_0 ϵ\epsilon XX Guess midpoint, switch to pop q1q_1 ϵ\epsilon (no change)
    q1q_1 aa aa Pop & match q1q_1 ϵ\epsilon (pop)
    q1q_1 bb bb Pop & match q1q_1 ϵ\epsilon (pop)
    q1q_1 ϵ\epsilon Z0Z_0 All matched, stack = Z0Z_0 q2q_2 ϵ\epsilon

    Formally:

    • δ(q0,a,X)={(q0,aX)}\delta(q_0, a, X) = \{(q_0, aX)\} for X∈{a,b,Z0}X \in \{a,b,Z_0\}
    • δ(q0,b,X)={(q0,bX)}\delta(q_0, b, X) = \{(q_0, bX)\} for X∈{a,b,Z0}X \in \{a,b,Z_0\}
    • δ(q0,ϵ,X)={(q1,X)}\delta(q_0, \epsilon, X) = \{(q_1, X)\} for X∈{a,b,Z0}X \in \{a,b,Z_0\} (midpoint guess)
    • δ(q1,a,a)={(q1,ϵ)}\delta(q_1, a, a) = \{(q_1, \epsilon)\}
    • δ(q1,b,b)={(q1,ϵ)}\delta(q_1, b, b) = \{(q_1, \epsilon)\}
    • δ(q1,ϵ,Z0)={(q2,ϵ)}\delta(q_1, \epsilon, Z_0) = \{(q_2, \epsilon)\}

    State Diagram

             a,b / X → aX,bX
          ┌───────────────────┐
          ▼                   │
      (q0)──ϵ, X/X──►(q1)──a/a:pop,b/b:pop──►(q1)
          │               │
          │               ϵ, Z0/ϵ
          │               ▼
          └──────────────►(q2)  [Accept]
    

    How It Works (Example: W=abW=ab → abbaabba)

    1. Push phase (q0q_0):

      • Read a, push a: stack = a Z0
      • Read b, push b: stack = b a Z0
      • Guess midpoint (ϵ\epsilon): go to q1q_1, stack unchanged b a Z0
    2. Pop phase (q1q_1):

      • Read b, top=b → pop → stack = a Z0
      • Read a, top=a → pop → stack = Z0
      • Input exhausted, ϵ\epsilon-transition on Z0Z_0 → q2q_2
    3. Accept: q2∈Fq_2 \in F, or stack = Z0Z_0 (empty-stack acceptance).


    Acceptance Modes

    Mode Condition
    Final State Reach q2∈Fq_2 \in F
    Empty Stack After reading all input, stack = Z0Z_0 (all pushed symbols matched and popped, only Z0Z_0 remains)

    Both equivalent here; PDA accepts by both.


    Why Nondeterministic?

    • The ϵ\epsilon-transition from q0q_0 to q1q_1 guesses the midpoint.
    • For odd-length strings (not in LL), no guess works → rejects.
    • For WWrWW^r, correct guess at exact middle → accepts.
    • DPDA cannot guess midpoint deterministically → LL not DCFL.

    Alternative: CFG

    S→aSa∣bSb∣ϵS \rightarrow aSa \mid bSb \mid \epsilon generates LL.


    Final Answer

    NPDA with 3 states (q0,q1,q2q_0, q_1, q_2):

    • q0q_0: push a,ba,b onto stack while reading first half
    • ϵ\epsilon-transition: guess midpoint, switch to q1q_1
    • q1q_1: pop & match each input symbol with stack top
    • ϵ\epsilon on Z0Z_0: accept (q2q_2)
    • Accepts by final state q2q_2 and empty stack (Z0Z_0 only).
  15. Q3b. Eliminate \varepsilon, unit, and useless productions from the grammar: A → bA | Bba | aa B → aba | b | D C → CA | AC | B D → a | \varepsilon20237m

    Module 2: Context-Free Languages (CFL) and PDA

    Eliminate ε\varepsilon, unit, and useless productions from the grammar:

    A → bA | Bba | aa
    B → aba | b | D
    C → CA | AC | B
    D → a | ε\varepsilon

    View this question on its own page →
  16. Q4a. Define Chomsky Normal Form. Convert the CFG: S → aSb | ab | Aa A → aab to CNF.20237m

    Module 2: Context-Free Languages (CFL) and PDA

    Define Chomsky Normal Form. Convert the CFG:

    S → aSb | ab | Aa
    A → aab

    to CNF.

    View this question on its own page →
  17. Q4b. Obtain the regular expression for the given DFA. ![image](https://res.cloudinary.com/djkpavwmp/image/upload/v1766231140/portfolio_assets/fbcklkz4il80phefuvuo.png)20237m

    Module 1: Introduction & Regular Languages

    Obtain the regular expression for the given DFA.

    image

    View this question on its own page →
  18. Q5a. Prove that if L_1 and L_2 are regular, then L_1 \cup L_2 is regular.20237m

    Module 1: Introduction & Regular Languages

    Prove that if L1L_1 and L2L_2 are regular, then L1∪L2L_1 \cup L_2 is regular.

    View this question on its own page →
  19. Q5b. Design a Turing machine that recognizes strings containing equal number of 0’s and 1’s.20237m

    Module 4: Turing Machines (TM)

    Design a Turing machine that recognizes strings containing equal number of 00’s and 11’s.

    View this question on its own page →
  20. Q6a. Given the \varepsilon-NFA, compute \varepsilon-closures and convert to DFA. | State | \varepsilon-transition | a-transition | b-transition | |-------|--------------------------|--------------|--------------| | → | {r} | {q} | {p,r} | | q | ∅ | {p} | ∅ | | r | {p,q} | {r} | {p} |20237m

    Module 1: Introduction & Regular Languages

    Given the ε\varepsilon-NFA, compute ε\varepsilon-closures and convert to DFA.

    State ε\varepsilon-transition a-transition b-transition
    → {r} {q} {p,r}
    q ∅ {p} ∅
    r {p,q} {r} {p}
    View this question on its own page →
  21. Q6b. Construct NFA for the regular expression: (0+1)^*00(0+1)^*20237m

    Module 1: Introduction & Regular Languages

    Construct NFA for the regular expression:

    (0+1)∗00(0+1)∗ (0+1)^*00(0+1)^*

    View this question on its own page →
  22. Budget App•POCKETLY

    Pocketly on Android

    Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.

    Install Pocketly
  23. Q7a. Construct NPDA for the grammar: S \to \alpha ABB \mid \alpha AA \\ A \to \alpha BB \mid \alpha \\ B \to bBB \mid A20237m

    Module 2: Context-Free Languages (CFL) and PDA

    Construct NPDA for the grammar:

    S→αABB∣αAAA→αBB∣αB→bBB∣A S \to \alpha ABB \mid \alpha AA \\ A \to \alpha BB \mid \alpha \\ B \to bBB \mid A

    View this question on its own page →
  24. Q7b. Prove the identity: (1+00^*1) + (1+00^*1)(0+10^*1)^*(0+10^*1) = 0^*1(0+10^*1)^*20237m

    Module 1: Introduction & Regular Languages

    Prove the identity:

    (1+00∗1)+(1+00∗1)(0+10∗1)∗(0+10∗1)=0∗1(0+10∗1)∗ (1+00^*1) + (1+00^*1)(0+10^*1)^*(0+10^*1) = 0^*1(0+10^*1)^*

    View this question on its own page →
  25. Q8a. Construct a Moore machine equivalent to the given Mealy machine.20237m

    Module 1: Introduction & Regular Languages

    Construct a Moore machine equivalent to the given Mealy machine.

    View this question on its own page →
  26. Q8b. Given the grammar: S \to aB \mid ba \\ B \to b \mid bs \mid aBB For the string aaabbabbba find: 1. Leftmost derivation 2. Rightmost derivation 3. Parse tree20237m

    Module 2: Context-Free Languages (CFL) and PDA

    Given the grammar:

    S→aB∣baB→b∣bs∣aBB S \to aB \mid ba \\ B \to b \mid bs \mid aBB

    For the string aaabbabbbaaaabbabbba find:

    1. Leftmost derivation
    2. Rightmost derivation
    3. Parse tree
    View this question on its own page →
  27. Q9a. Write short notes on: Post Correspondence Problem.20237m

    Module 5: Undecidability

    Write short notes on: Post Correspondence Problem.

    View this question on its own page →
  28. Q9b. Write short notes on: Multi-tape Turing Machine.20237m

    Module 4: Turing Machines (TM)

    Write short notes on: Multi-tape Turing Machine.

    View this question on its own page →
  29. Q9c. Write short notes on: NP-hard and NP-complete problems.20237m

    Module 5: Undecidability

    Write short notes on: NP-hard and NP-complete problems.

    View this question on its own page →
  30. Q9d. Write short notes on: Pumping lemma for CFL.20237m

    Module 2: Context-Free Languages (CFL) and PDA

    Write short notes on: Pumping lemma for CFL.

    View this question on its own page →
Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.