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

COS3701 Assignment 3 (COMPLETE ANSWERS) 2025 - DUE 2025

Rating
-
Sold
-
Pages
13
Grade
A+
Uploaded on
03-08-2025
Written in
2025/2026

Question 1 [10] Given that L1 = (aa)* and L2 = (a + b)*ab(a + b)*. Find grammars for L1 and L2. Then use Theorem 37 to find L1L2. Question 3 [10] Using theorem 42 algorithm to determine whether the following grammar generate any words. S AB A BC C DA B CD D a A b Look at the reformulated version of Theorem 42 in your online study units Question 4 [15] Build a Turing Machine (TM) that • accepts all words in {an bn am | n ≥ 0; m > n} • loops forever on all words starting with b, and • rejects all other words. Assume that the alphabet is Σ = {a, b} Question 5 [15] Build a 2PDA that accepts the language {a2nbnanb2n | n > 0}.

Show more Read less









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

Document information

Uploaded on
August 3, 2025
Number of pages
13
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

COS3701 Assignment 3
(COMPLETE ANSWERS)
2025 - DUE 2025

For assistance contact
Email:

, Question 1: Grammars for Concatenated Languages
1. Grammars for L1=(aa)∗ and L2=(a+b)∗ab(a+b)∗Error! Filename not specified.
A grammar for a regular language is a regular grammar, also known as a right-linear grammar. It
has productions of the form A→wB or A→w, where A and B are non-terminals and w is a string
of terminals.
Grammar for L1=(aa)∗Error! Filename not specified.
The language L1 consists of strings with an even number of 'a's, including the empty string (Λ).
 Start symbol: S1Error! Filename not specified.
 Terminals: {a}Error! Filename not specified.
 Productions: S1→aaS1 S1→ΛError! Filename not specified.
This grammar correctly generates all strings in L1. The first production allows the generation of
pairs of 'a's, and the second production allows the derivation to terminate, including the case
where no 'a's are generated (the empty string).
Grammar for L2=(a+b)∗ab(a+b)∗Error! Filename not specified.
The language L2 consists of all strings over the alphabet {a,b} that contain the substring "ab".
 Start symbol: S2Error! Filename not specified.
 Terminals: {a,b}Error! Filename not specified.
 Non-terminals: {S2,A}Error! Filename not specified.
 Productions: S2→aS2∣bS2∣abA A→aA∣bA∣ΛError! Filename not specified.
The productions for S2 first generate any arbitrary string of 'a's and 'b's (the (a+b)∗ part) before
moving to the core substring "ab". Once "ab" is generated, the non-terminal A takes over to
generate the final arbitrary string of 'a's and 'b's (the second (a+b)∗ part). The production A→Λ
allows this final part to be the empty string.
2. Using Theorem 37 to find the grammar for L1L2Error! Filename not specified.
Theorem 37 states that if a grammar G1 generates L1 and a grammar G2 generates L2, a
grammar for the concatenated language L1L2 can be constructed. A common formulation of this
theorem for regular languages involves modifying the productions of G1 that contain the empty
string (Λ).
The procedure is as follows:
1. Take all the productions of G1 and G2.
2. If the start symbol of G1, S1, has a production S1→Λ, replace this production with S1
→S2, where S2 is the start symbol of G2.

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.
gabrielmusyoka940 db
View profile
Follow You need to be logged in order to follow users or courses
Sold
1457
Member since
2 year
Number of followers
247
Documents
1488
Last sold
1 week ago
Bstudy

provides latest exam paper

3,2

214 reviews

5
68
4
28
3
49
2
20
1
49

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 exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT 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