COS3701 ASSIGNMENT 2
2024 (365071) - DUE 27
JUNE 2024
[Company address]
, COS3701 Assignment 2 2024 (365071) - DUE 27 June 2024
Question 1 [15]
Build a DPDA to show that the language L = {(ba)na(ab)n-2 | n > 2} is
deterministic context free.
Deterministic Pushdown Automaton (DPDA) for L = {(ba)na(ab)n-2 | n > 2}
States:
• q0: Start state
• q1: Reading the first part (n repetitions of "ba")
• q2: Reading the middle "aaa"
• q3: Reading the second part (n-2 repetitions of "ba")
• q4: Accepting state
Stack Alphabet:
• X: Symbol used for bookkeeping
Input Alphabet:
• Σ = {a, b}
Transition Function (δ):
δ is a function that maps (state, input symbol, top stack symbol) to a next state
and a stack symbol to push (or ε for no push). Here's the table representation:
| δ(q, σ, z) | |---|---| | δ(q0, a, -) | (q1, X) | // Start reading "ba" and push X |
δ(q0, b, -) | - | // Reject if input doesn't start with "a" (deterministic) | δ(q1, b,
X) | (q1, X) | // Read "b" in "ba" and keep X | δ(q1, a, X) | (q2, ε) | // Read "a"
in "ba", consume X, and move to middle "aaa" | δ(q2, a, -) | (q2, a) | // Read
first "a" in "aaa" and push "a" | δ(q2, a, a) | (q2, aa) | // Read second "a" in
"aaa" and push another "a" | δ(q2, a, aa) | (q3, X) | // Read third "a" in
For exam pack with questions and answers, quality notes, assignments and exam
help:
email:
WhatsApp: +254792947610
2024 (365071) - DUE 27
JUNE 2024
[Company address]
, COS3701 Assignment 2 2024 (365071) - DUE 27 June 2024
Question 1 [15]
Build a DPDA to show that the language L = {(ba)na(ab)n-2 | n > 2} is
deterministic context free.
Deterministic Pushdown Automaton (DPDA) for L = {(ba)na(ab)n-2 | n > 2}
States:
• q0: Start state
• q1: Reading the first part (n repetitions of "ba")
• q2: Reading the middle "aaa"
• q3: Reading the second part (n-2 repetitions of "ba")
• q4: Accepting state
Stack Alphabet:
• X: Symbol used for bookkeeping
Input Alphabet:
• Σ = {a, b}
Transition Function (δ):
δ is a function that maps (state, input symbol, top stack symbol) to a next state
and a stack symbol to push (or ε for no push). Here's the table representation:
| δ(q, σ, z) | |---|---| | δ(q0, a, -) | (q1, X) | // Start reading "ba" and push X |
δ(q0, b, -) | - | // Reject if input doesn't start with "a" (deterministic) | δ(q1, b,
X) | (q1, X) | // Read "b" in "ba" and keep X | δ(q1, a, X) | (q2, ε) | // Read "a"
in "ba", consume X, and move to middle "aaa" | δ(q2, a, -) | (q2, a) | // Read
first "a" in "aaa" and push "a" | δ(q2, a, a) | (q2, aa) | // Read second "a" in
"aaa" and push another "a" | δ(q2, a, aa) | (q3, X) | // Read third "a" in
For exam pack with questions and answers, quality notes, assignments and exam
help:
email:
WhatsApp: +254792947610