0% found this document useful (0 votes)
4 views3 pages

BC210200353 Assignment - 01 CS - 402

The document contains an assignment on the Theory of Automata, detailing solutions for regular expressions and finite automata. It includes the regular expression for strings ending with one 'b' preceded by any number of 'a's, and calculations for the number of distinct strings generated by various regular expressions. The assignment also provides visual representations of finite automata and enumerates the possible strings for specified lengths.

Uploaded by

bybitt12345
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

BC210200353 Assignment - 01 CS - 402

The document contains an assignment on the Theory of Automata, detailing solutions for regular expressions and finite automata. It includes the regular expression for strings ending with one 'b' preceded by any number of 'a's, and calculations for the number of distinct strings generated by various regular expressions. The assignment also provides visual representations of finite automata and enumerates the possible strings for specified lengths.

Uploaded by

bybitt12345
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

THEORY OF AUTOMATA CS_402

ASSIGNMENT_01
VU ID: BC210200353 NAME: TALHA SAJID
QUESTION_1:

a. Write the regular expression for language consists of all strings that ends and have exact
one b and can have any number of a’s (excluding none) before it, over the set of
alphabets Σ={a,b}.

Solution:
Regular expression for the language:
The strings that make up the language include:
End with exactly one b.
Can have at least one a before the b, but it can have any number of a's.
No b can appear in the string before the last b.
Thus, the regular expression can be written as:
a+b

b. Draw the Finite Automaton for above language?

Solution: a

a b
q0 q1
q2

QUESTION_2

Consider the language L of strings, defined over ∑= {a, b}, Write the answers of the following:

a) If the regular expression is (𝑎𝑏)*, how many different strings of length 4 are in this
language?

Solution:
Regular Expression: (ab)*

The string "ab" has zero or more repetitions, as indicated by this regular expression.
For strings of length 4:
 Each "ab" contributes 2 characters.
 To create a string of length 4, we need two repetitions of "ab":
 String: "abab"

The number of 4 length strings in this language is:


 1 (only "abab")

b) If the regular expression is (𝑎∣𝑏)2, how many strings of length 2 can it generate?
Solution:
Regular Expression: (a|b)²
Two characters are permitted under this regular expression, and each character may
independently be either "a" or "b."
The | operator represents a choice between 'a' or 'b'.
Total number of strings of length 2:
 Each character has 2 options ('a' or 'b').
 For two positions, the total number of strings is: 2x2=4
Generated strings:
 aa, ab, ba, bb
Number of strings of length 2:
 4

c) If the regular expression is (𝑎𝑏∣𝑏𝑎)2, how many distinct strings of length 4 can be
generated?
Solution:
c) Regular Expression: (ab|ba)2

This regular expression permits "ab" or "ba" to be repeated twice.

For strings of length 4:


1. A 2-character substring ("ab" or "ba") is produced with each repetition.
2. For every repetition, there are 2 options: "ab" or "ba".
3. For two repetitions, the total number of strings is: 2×2=4
4. Generated strings:
"abab" (ab followed by ab)
"abba" (ab followed by ba)
"baab" (ba followed by ab)
"baba" (ba followed by ba)
Number of distinct strings of length 4:
 4

You might also like