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 Memo | Due July 2025

Rating
-
Sold
1
Pages
12
Grade
A+
Uploaded on
02-07-2025
Written in
2024/2025

COS3701 Assignment 2 Memo | Due July 2025. This document contains a fully answered assignment with complete answers to all questions and tasks. Every section is carefully completed to ensure a guaranteed pass. Perfect for guaranteed pass, high marks, and peace of mind.

Show more Read less









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

Document information

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

Subjects

Content preview

, PLEASE USE THIS DOCUMENT AS A GUIDE TO ANSWER YOUR ASSIGNMENT

 Question 1

1. Find CFGs for all words that do not have the substring aba over the alphabet Σ = {a b}.

Step-by-step Idea
Define non-terminal symbols that track the recent history of characters so prevent "aba" from
forming.

Define the grammar in a way that ensures:
 Don’t produce the exact sequence "aba".
 Do allow any combination of as and bs except the one that introduces "aba".

Grammar Overview
Define non-terminals:

 S — the start symbol, generates all safe strings.
 A — last character was a
 B — last character was b
 AA — last two characters were aa
 AB — last two characters were ab (danger zone — can't allow an a next!)
 avoid allowing transitions that would complete the forbidden "aba".

CFG Rules
 S → aA | bB | ε // Start with a or b, or empty string
 A → aAA | bB // 'a' followed by something, or safe 'b'
 AA → aAA | bB // 'aa...' — okay as long as not followed by 'ba'
 B → aA | bB // 'b' followed by anything safe
 AB → bB // After 'ab' only 'b' is allowed (not 'a')

Final CFG
Define non-terminals:

 S – any valid string
 X – the string ends in a
 Y – the string ends in ab

Rules:
 S → aX | bS | ε // Start with a or b, or end (empty string)
 X → aX | bY // After an 'a', if 'b' follows, we go to Y
 Y → bS // From 'ab', only a 'b' is allowed next

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.
Aimark94 University of South Africa (Unisa)
View profile
Follow You need to be logged in order to follow users or courses
Sold
6575
Member since
6 year
Number of followers
3168
Documents
1326
Last sold
3 weeks ago
Simple & Affordable Study Materials

Study Packs & Assignments

4,2

520 reviews

5
277
4
124
3
74
2
14
1
31

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