Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4,6 TrustPilot
logo-home
Document preview thumbnail
Preview 3 out of 23 pages
Exam (elaborations)

COS3701 Assignment 3 (COMPLETE ANSWERS) 2025 - DUE 2025; 100% TRUSTED Complete, trusted solutions and explanations.. Ensure your success with us..

Document preview thumbnail
Preview 3 out of 23 pages

COS3701 Assignment 3 (COMPLETE ANSWERS) 2025 - DUE 2025; 100% TRUSTED Complete, trusted solutions and explanations.. Ensure your success with us..

Content preview

[TYPE THE COMPANY NAME]




COS3701 Assignment 3
(COMPLETE ANSWERS)
2025
NO PLAGIARISM

[Pick the date]




[Type the abstract of the document here. The abstract is typically a short summary of the contents of
the document. Type the abstract of the document here. The abstract is typically a short summary of
the contents of the document.]

,Exam (elaborations)
COS3701 Assignment 3 (COMPLETE
ANSWERS) 2025
Course

 Theoretical Computer Science III (COS3701)
 Institution
 University Of South Africa (Unisa)
 Book
 Theoretical Computer Science

COS3701 Assignment 3 (COMPLETE ANSWERS) 2025 - DUE 2025; 100%
TRUSTED Complete, trusted solutions and explanations.. Ensure your success
with us..



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.

Step 1: Understanding the Languages
 L₁ = (aa)*
This language contains any number (including zero) of aa repetitions. Examples: ε, aa,
aaaa, aaaaaa, ...
 L₂ = (a + b)*ab(a + b)*
This language contains all strings over {a, b} that contain at least one occurrence of the
substring "ab".




Step 2: Define Grammars for L₁ and L₂
Grammar for L₁ = (aa)*

Let’s define a grammar G₁ = (V₁, Σ, R₁, S₁):

 V₁ = {S}
 Σ = {a}
 R₁:
o S → aaS | ε

This generates strings with any number of "aa" blocks.

, Grammar for L₂ = (a + b)*ab(a + b)*

Let’s define a grammar G₂ = (V₂, Σ, R₂, S₂):

 V₂ = {S, A, B}
 Σ = {a, b}
 R₂:
o S → aS | bS | A
o A → aB
o B → bC
o C → aC | bC | ε

Explanation:

 S → aS | bS allows any prefix before ab
 A → aB and B → bC enforces "ab"
 C generates any suffix (a or b)*




Step 3: Use Theorem 37 (Concatenation of Context-Free
Languages)
Theorem 37:

If L₁ and L₂ are context-free languages, then so is their concatenation L₁L₂, and there exists a
context-free grammar for it.

Constructing the Grammar for L₁L₂

Let G₁ = (V₁, Σ, R₁, S₁) and G₂ = (V₂, Σ, R₂, S₂)

Define a new grammar G = (V, Σ, R, S) where:

 V = V₁ ∪ V₂ ∪ {S}
 S is the new start symbol.
 R = R₁ ∪ R₂ ∪ {S → S₁S₂}

So:

Final Grammar G for L₁L₂

Connected book
 image
Mario Coppo, Elena Lodi Theoretical Computer Science
Publisher: 2005 ISBN: 9783540291060 Edition: Unknown

Document information

Uploaded on
July 2, 2025
Number of pages
23
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
R45,24

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

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.
tabithamwendwa73
3,5
(68)
Sold
413
Followers
82
Items
1162
Last sold
1 month ago



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

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions