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 25 pages
Exam (elaborations)

COS3701 Assignment 2 (COMPLETE ANSWERS) 2025

Document preview thumbnail
Preview 3 out of 25 pages

COS3701 Assignment 2 (COMPLETE ANSWERS) 2025

Content preview

,COS3701 Assignment 2 (COMPLETE
ANSWERS) 2025 – DUE 2025; 100% TRUSTED
Complete, trusted solutions and
explanations.
Question 1 10 Find CFGs for all words that do not
have the substring aba over the alphabet Σ = {a
b}. Question 2 10 Convert the grammar below to
CNF (Hint: Consult the online study material) S aX |
Yb X ZXYZ | a Y b | bY | ᴧ Z a | ᴧ Question 3 15
Build a DPDA that accepts the language L =
{(ab)n(ba)n-2| n > 2}. Question 4 15 Prove that
the language L = {an+1b2n (aa)n b | n > 0} is
non-context free. Use the pumping lemma with
length.


Question 1 (10 Marks):
Find a CFG for all words that do not have the
substring “aba” over the alphabet Σ = {a, b}.


Let’s construct a grammar that avoids generating
“aba”. We’ll design states to ensure “aba” cannot
be formed.

, Let the variables simulate the end of the last few
characters:


S → start symbol.


A → last character was ‘a’.


B → last character was ‘b’.


AA → last two characters were “aa”.


AB → last two characters were “ab” (be careful
here — adding an a now would create “aba”, which
we must avoid).


BB → last two characters were “bb”, etc.


CFG:


Csharp
Copy code

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

Document information

Uploaded on
July 1, 2025
Number of pages
25
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$2.77

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.
THEBLAZE1
3.6
(113)
Sold
719
Followers
173
Items
1098
Last sold
3 weeks ago



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

Working on your references?

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

Working on your references?

Frequently asked questions