100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
COS3701 Assignment 2 (COMPLETE ANSWERS) 2024 (365071) - DUE 27 June 2024 R46,75   Add to cart

Exam (elaborations)

COS3701 Assignment 2 (COMPLETE ANSWERS) 2024 (365071) - DUE 27 June 2024

 11 views  0 purchase

100% TRUSTED workings, explanations and solutions: For assistance

Preview 2 out of 5  pages

  • April 27, 2024
  • 5
  • 2023/2024
  • Exam (elaborations)
  • Questions & answers
All documents for this subject (13)
avatar-seller
examexpert01
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

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

Quick and easy check-out

You can quickly pay through EFT, credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

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 this summary from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller examexpert01. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy this summary for R46,75. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

72042 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy summaries for 14 years now

Start selling
R46,75
  • (0)
  Buy now