0% found this document useful (0 votes)
70 views

Theory of Automata - CS402 Spring 2004 Assignment 01 Solution

The document contains solutions to 5 questions regarding formal languages and automata. For question 1, the document determines the number of strings of various lengths that can be formed from the language S* where S={ab,ba}. For question 2, it provides the recursive definition of the language of numbers divisible by 3. For question 3, it gives regular expressions to describe the languages of 3 finite automata. For question 4, it constructs a finite automaton that accepts strings with an odd number of a's and b's. For question 5, it provides transition graphs for two languages defined by regular expressions.

Uploaded by

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

Theory of Automata - CS402 Spring 2004 Assignment 01 Solution

The document contains solutions to 5 questions regarding formal languages and automata. For question 1, the document determines the number of strings of various lengths that can be formed from the language S* where S={ab,ba}. For question 2, it provides the recursive definition of the language of numbers divisible by 3. For question 3, it gives regular expressions to describe the languages of 3 finite automata. For question 4, it constructs a finite automaton that accepts strings with an odd number of a's and b's. For question 5, it provides transition graphs for two languages defined by regular expressions.

Uploaded by

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

Solution Assignment # 1

Q. 1. Consider the language S*, where S= {ab, ba}


How many words does this language have of length 4? Of length 5? Of length 6? Of length 7?
What can be said in general?

Solution:

Here S is not an alphabet but also it is a set of substrings. That’s why we should take
length of bb as 2 instead of 1.

Strings of length 4 = 22 = 4

Strings of length 5 = 0

Strings of length 6 = 23 = 8

Strings of length 7 = 0

In general, number of EVEN length strings will be 2 N/2 and number of ODD length strings will be
always 0. (N denotes length of string).

Q. 2. Give the recursive definition of language “number multiple of three” L={3, 6, 9, 12, ……}

Solution:

Step 1

3 is in L
Step 2

If x is in L, then is x + 3
Step 3

No strings except those constructed in above, are allowed to be in L.

Q. 3. Describe the languages given by the following FA’s using RE’s.

b
+
a)
a,b
a

a +
- a,b
a,b

a
b +
a,b

b
Solution:

(a + b) a (a + b)* + ab

b)

b b b
a a

Solution:

(b*ab*ab*ab*)*

Q. 4. For ∑={a, b}, build and FA for language Odd-Odd “all words with Odd a’s and Odd b’s ”

Solution:
b
1- 3
b

a a a a

b
2 4+
b

Q. 5. For ∑={a, b}, build TG for following languages.

“Words starting and ending in double letters”. RE is (aa + bb)+ (aa + bb)(a+ b)*(aa+bb)

Solution:
+
aa, bb

-
a, b

aa, bb aa, bb
+
(ii) Words not having number of 2 b’s at consecutive places (there should be no string bb in the
any word). RE is a*(baa*)*(b+ Λ)

Solution:

a a
b
+ Λ +
-
a
Λ,b

NOTE: we can generalize many TG’s for a single language so above given solution is not the only
TG for said language but also it is only one of possible solutions.

You might also like