100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Examen

COS3701 Assignment 2 (COMPLETE ANSWERS) 2025

Puntuación
-
Vendido
5
Páginas
28
Grado
A+
Subido en
02-07-2025
Escrito en
2024/2025

COS3701 Assignment 2 (COMPLETE ANSWERS) 2025

Institución
Grado










Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Libro relacionado

Escuela, estudio y materia

Institución
Grado

Información del documento

Subido en
2 de julio de 2025
Número de páginas
28
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

Vista previa del contenido

[TYPE THE COMPANY NAME]




COS3701 Assignment 2
(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 2 (COMPLETE
ANSWERS) 2025
Course

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

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



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

Solution: We want to find a Context-Free Grammar (CFG) for the language
L={w∈{a,b}∗∣w does not have the substring aba}.

Let's break down the possible structures of words that do not contain "aba".

A word that does not contain "aba" can be thought of as a sequence of blocks, where no block is
"aba" and no combination of blocks forms "aba".

Consider the states we can be in when building a string that avoids "aba":

1. Initial state (S): We haven't seen any part of "aba" or have just completed a safe
sequence.
2. Seen 'a' (A): We have just seen an 'a', which could be the start of "aba".
3. Seen 'ab' (AB): We have just seen 'ab', which could be the start of "aba".

Let's define the productions based on these states.

Let S be the start symbol. Let A be a non-terminal representing the state where the last character
read was 'a' (and we haven't formed "aba"). Let B be a non-terminal representing the state where
the last characters read were 'ab' (and we haven't formed "aba").

From the start symbol S:

 We can have an empty string: S→ϵ

,  We can start with 'b': S→bS (we are still in a "safe" state after 'b')
 We can start with 'a': S→aA (we've seen 'a', now in state A)

From state A (last character was 'a'):

 If we see 'a' again: A→aA (we still have 'a' as the last character, no "aba" formed)
 If we see 'b': A→bB (we've seen 'ab', now in state B)
 We can end the string here: A→ϵ (the string ends with 'a', no "aba")

From state B (last characters were 'ab'):

 If we see 'a': This would form "aba", which is not allowed. So, B cannot directly
transition to a state that accepts 'a'. However, this is where it gets tricky for CFGs. A CFG
cannot "reject" a character in the same way a DFA does. Instead, the grammar simply
won't have a production for that sequence.
 If we see 'b': B→bS (we've seen 'abb', which is safe, and we effectively reset to a "safe"
state S because the last 'b' doesn't start "aba")
 We can end the string here: B→ϵ (the string ends with 'ab', no "aba")

Let's refine this approach. Instead of thinking about states in a DFA-like manner, let's consider
the structure of strings that avoid "aba".

A string avoiding "aba" can be:

1. Any string not ending in 'a' or 'ab' that avoids "aba".
2. A string ending in 'a' that avoids "aba".
3. A string ending in 'ab' that avoids "aba".

Let S be the start symbol. Consider the blocks that are "safe": 'b', 'a'. If we see 'ab', the next
character must not be 'a'.

Let's try a different approach, based on the idea that any string that does not contain 'aba' can be
formed by:

 Only 'b's: b∗
 Only 'a's: a∗
 Combinations that avoid 'aba'.

A common technique is to consider what happens if we don't see the forbidden substring.

Let's define non-terminals based on the suffix we've built so far that could be a prefix of 'aba'.

S: Generates all words that do not have 'aba'. S→bS S→aA S→ϵ
$2.70
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
tabithamwendwa73 Chamberlain College Nursing
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
379
Miembro desde
1 año
Número de seguidores
82
Documentos
1032
Última venta
1 mes hace
brilliant tutorials

brilliant tutorials Attention all students! Are you struggling with a particular subject or just need some extra support to help you succeed? Look no further than our expert tutorial services! Our experienced tutors provide personalized one-on-one sessions to help you overcome your academic challenges and reach your full potential. Whether you need help with any module, our tutors are here to help. With flexible scheduling and competitive pricing, there\'s no reason to struggle on your own. Invest in your academic success today and book a tutorial session with us

Lee mas Leer menos
3.6

64 reseñas

5
28
4
14
3
3
2
4
1
15

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes