Fall 2024 - CS402 - 1 - Assignment
Fall 2024 - CS402 - 1 - Assignment
Assignment # 01
Fall 2024 Deadline Date
November 22, 2024
Question No. 1
The language consists of all strings over the alphabet Σ = {a, b} that:
(a+)*b
Explanation:
(a+)*: This part represents zero or more 'a's, but with the condition that at least
one 'a' is required (as indicated by the + within the parentheses).
b: The string must end with exactly one 'b'.
The construction (a+)*b ensures that there is one or more 'a's (since 'a+' means
at least one 'a') before the 'b', and the string ends with exactly one 'b'.
To draw a Finite Automaton (FA) that recognizes this language, follow these steps:
1. State 1 (Initial State): This is where the automaton starts. It can loop on 'a'
(indicating one or more 'a's are allowed before a 'b').
2. State 2: This state is reached when a 'b' is encountered. From this state, the
automaton can no longer accept any additional 'a's or 'b's.
3. Final State (State 2): The automaton must reach this state after reading
exactly one 'b', and no further symbols can be processed.
a) Regular Expression is (ab)*, how many different strings of length 4 are in this
language?
The regular expression (ab)* represents any number (including zero) of repetitions of
the sequence "ab". Since the string is of length 4, we need to determine how many
different ways the string can be formed using the pattern "ab".
"abab"
"baba"
The regular expression (a∣b)² represents all strings of length 2 where each position
can independently be either 'a' or 'b'.
The total number of different strings of length 2 that can be formed is:
"aa"
"ab"
"ba"
"bb"
The regular expression (ab∣ ba)² means that we are forming strings of length 4 by
repeating either "ab" or "ba" exactly twice.
"abab"
"baba"
1. Regular expression for the language that ends with one 'b' and has at least one
'a' before it: *(a+)b
2. Finite Automaton:
For Question 2: