• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 5 pages
Other

COS3701 Assignment 2 Answers 2026

Document preview thumbnail
Preview 2 out of 5 pages

COS3701 Assignment 2 Answers 2026 with explanations

Content preview

COS3701
ASSIGNMENT 2
2026


Rewritten study reference

, Please note: Change the words of the Greek letters to the actual Greek letters.


Question 1 (10)
Find a CFG for all words over Sigma = {a, b} that do not contain the substring aba.

Answer
G = (V, Sigma, R, S)

V = {S, A, B}
Sigma = {a, b}

Productions:
S -> bS | aA | epsilon
A -> aA | bB | epsilon
B -> bS | epsilon

How the answer is obtained
Track how close the generated word is to accidentally forming the forbidden pattern aba.
• S is the safe state: no useful part of aba has just been formed.
• A means the last relevant symbol was a, so the word has started to resemble aba.
• B means the ending is ab. From here, an a would create aba, so no rule from B may produce a.
The rule B -> bS | epsilon is the important restriction: after ab, the grammar either stops or adds b. It never
adds a, so aba cannot appear.


Question 2 (10)
Convert the grammar below to Chomsky Normal Form (CNF).
S -> aX | Yb
X -> ZXYZ | a
Y -> b | bY | epsilon
Z -> a | epsilon

Answer
Nullable variables:
Y, Z
After removing epsilon-productions:
S -> aX | Yb | b
X -> ZXYZ | XYZ | ZXZ | ZXY | XZ | XY | ZX | a
Y -> b | bY
Z -> a
Introduce terminal variables:
A -> a
B -> b

Rewritten study reference

Document information

Uploaded on
May 26, 2026
Number of pages
5
Written in
2025/2026
Type
Other
Person
Unknown
$9.32

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.
Sold
28
Followers
23
Items
4
Last sold
1 year 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 revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight 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 smashed 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