COS3701
Assignment 2
(COMPLETE
ANSWERS)
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.
To show that the language �={(��)�(��)�−2∣�>2}L={(ba)n(ab)n−2∣n>2}
is deterministic context-free, we can construct a deterministic pushdown automaton (DPDA) that
recognizes it. Here's the high-level idea of the DPDA:
1. The DPDA will push symbols onto the stack for each occurrence of 'b' and 'a' in the input
string until it reads the second occurrence of 'a'.
2. Upon reading the second 'a', the DPDA will start popping symbols from the stack for
each occurrence of 'a' and 'b' until the stack is empty. If the stack becomes empty before
reaching the end of the input string, it accepts; otherwise, it rejects.
Here's the detailed construction:
1. State q0: The initial state. The DPDA starts here.
2. State q1: Push 'b' onto the stack for each 'b' encountered in the input.
3. State q2: Transition to this state when the first 'a' is encountered.
4. State q3: Push 'a' onto the stack for each 'a' encountered in the input until the second 'a' is
encountered.
5. State q4: Transition to this state upon reading the second 'a'.
6. State q5: Pop symbols from the stack for each 'a' or 'b' encountered in the input until the
stack is empty. If the end of the input is reached, accept; otherwise, reject.
The transitions for the DPDA are as follows:
�(�0,�,�)={(�1,�)}δ(q0,b,ε)={(q1,b)} (Push 'b' onto the stack)
�(�1,�,�)={(�1,��)}δ(q1,b,b)={(q1,bb)} (Push 'b' onto the stack)
�(�1,�,�)={(�2,�)}δ(q1,a,ε)={(q2,ε)} (Transition to q2 upon
encountering the first 'a')
�(�2,�,�)={(�3,�)}δ(q2,a,ε)={(q3,a)} (Push 'a' onto the stack)
�(�3,�,�)={(�3,��)}δ(q3,a,a)={(q3,aa)} (Push 'a' onto the stack)
�(�3,�,�)={(�3,�)}δ(q3,b,ε)={(q3,ε)} (Ignore additional 'b's until the
second 'a' is encountered)
�(�3,�,�)={(�4,�)}δ(q3,a,ε)={(q4,ε)} (Transition to q4 upon
encountering the second 'a')
�(�4,�,�)={(�5,�)}δ(q4,a,ε)={(q5,ε)} (Transition to q5 upon
encountering any 'a' after the second 'a')
�(�4,�,�)={(�5,�)}δ(q4,b,ε)={(q5,ε)} (Transition to q5 upon
encountering any 'b' after the second 'a')
�(�5,�,�)={(�5,�)}δ(q5,a,ε)={(q5,ε)} (Pop 'a' from the stack)
�(�5,�,�)={(�5,�)}δ(q5,b,ε)={(q5,ε)} (Pop 'b' from the stack)
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Solutionist. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $2.50. You're not tied to anything after your purchase.