100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

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

Rating
-
Sold
-
Pages
5
Grade
A+
Uploaded on
27-04-2024
Written in
2023/2024

100% TRUSTED workings, explanations and solutions: For assistance

Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Course

Document information

Uploaded on
April 27, 2024
Number of pages
5
Written in
2023/2024
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

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)

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
examexpert01 Chamberlain College Nursing
Follow You need to be logged in order to follow users or courses
Sold
195
Member since
2 year
Number of followers
111
Documents
937
Last sold
1 month ago

3.3

21 reviews

5
9
4
0
3
6
2
1
1
5

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions