Garantie de satisfaction à 100% Disponible immédiatement après paiement En ligne et en PDF Tu n'es attaché à rien 4,6 TrustPilot
logo-home
Examen

COS3701 Assignment 2 (COMPLETE ANSWERS) 2025

Note
-
Vendu
-
Pages
17
Grade
A+
Publié le
15-07-2025
Écrit en
2024/2025

100% TRUSTED WORKINGS, EXPLANATIONS & SOLUTIONS

Établissement
Cours










Oups ! Impossible de charger votre document. Réessayez ou contactez le support.

École, étude et sujet

Établissement
Cours

Infos sur le Document

Publié le
15 juillet 2025
Nombre de pages
17
Écrit en
2024/2025
Type
Examen
Contient
Questions et réponses

Sujets

Aperçu du contenu

COS3701
Assignment 2
(COMPLETE
ANSWERS) 2025
FOR MORE ASSISTANCE CONTACT:




100% TRUSTED WORKINGS, EXPLANATIONS
& SOLUTIONS

,COS3701 Assignment 2 (COMPLETE
ANSWERS) 2025
Question 1 10 Find CFGs for all words that do not have
the substring aba over the alphabet Σ = {a b}.
To construct a Context-Free Grammar (CFG) for all words over the alphabet Σ
= {a, b} that do not contain the substring "aba", we need to carefully design
rules that generate all such strings while preventing the forbidden pattern from
forming.


✅ Step-by-step approach:

We’ll define a CFG that:
 Generates all strings over {a, b}
 Avoids generating any string with "aba" as a substring


🎯 Key Idea
Keep track of the last few letters of the string being built, to avoid creating "aba".


📘 CFG Variables:

Let’s define the non-terminals as follows:
 S: Start symbol — generates all strings that avoid "aba"
 A: Last symbol was "a"
 AA: Last two symbols were "aa"
 B: Last symbol was "b"


🧩 Productions (CFG Rules)
We define the grammar as:
S → aA | bS | ε
A → aAA | bS (a followed by a = "aa" OR a followed by b is safe unless "ab" is

, followed by "a")
AA → aAA | bS (still safe until we get "aba")
Now let’s analyze the safety:
We must avoid the substring "aba".
So we disallow:
 From A, producing bA (i.e., forming "ab"), followed by a, which would
create "aba".
 Therefore, after "ab" we must not allow a.
So we’ll need to track when we just saw "ab" and prevent a next.


📘 Final CFG (safe version with tracking):

Let’s define new non-terminals:
 S: Start symbol.
 A: Previous symbol was a.
 AB: Previous two symbols were ab.
Now define productions:
S → aA | bS | ε
A → aA | bAB
AB → bS ; disallow `AB → a...` to avoid "aba"


✅ Explanation
 S → aA starts with a, moves to A
 A → bAB builds "ab" and moves to AB
 AB → bS continues only if next is b, so no AB → a..., avoiding "aba"
 All other transitions are safe and preserve valid strings.


🎓 Example strings generated:
 ε (empty string) ✅
 a✅
€2,55
Accéder à l'intégralité du document:

Garantie de satisfaction à 100%
Disponible immédiatement après paiement
En ligne et en PDF
Tu n'es attaché à rien

Faites connaissance avec le vendeur

Seller avatar
Les scores de réputation sont basés sur le nombre de documents qu'un vendeur a vendus contre paiement ainsi que sur les avis qu'il a reçu pour ces documents. Il y a trois niveaux: Bronze, Argent et Or. Plus la réputation est bonne, plus vous pouvez faire confiance sur la qualité du travail des vendeurs.
examexpert01 Chamberlain College Nursing
S'abonner Vous devez être connecté afin de suivre les étudiants ou les cours
Vendu
195
Membre depuis
2 année
Nombre de followers
111
Documents
937
Dernière vente
2 mois de cela

3,3

21 revues

5
9
4
0
3
6
2
1
1
5

Récemment consulté par vous

Pourquoi les étudiants choisissent Stuvia

Créé par d'autres étudiants, vérifié par les avis

Une qualité sur laquelle compter : rédigé par des étudiants qui ont réussi et évalué par d'autres qui ont utilisé ce document.

Le document ne convient pas ? Choisis un autre document

Aucun souci ! Tu peux sélectionner directement un autre document qui correspond mieux à ce que tu cherches.

Paye comme tu veux, apprends aussitôt

Aucun abonnement, aucun engagement. Paye selon tes habitudes par carte de crédit et télécharge ton document PDF instantanément.

Student with book image

“Acheté, téléchargé et réussi. C'est aussi simple que ça.”

Alisha Student

Foire aux questions