This action might not be possible to undo. Are you sure you want to continue?

Assignment 1

Question No.1

Marks: 4

a) Give regular expressions of the following languages over Σ={0,1}: 1. All strings having no pair of consecutive zeros. 2. All strings having exactly two 1’s or three 1’s not more than it. b) Show that the Regular expression ^ + 0(0+1)*+(0+1)*00(0+1)* is equivalent to ((0*1)*01*)* Solution: a) 1. RE for the language having all strings having no pair of consecutive zeros. (1 + 01)*(0 + 1*) Other possibilities might be (1 + 01)*(0 + λ) + 1* or (1 + 01)* + (1 + 01)*0 + 1*

2. RE for the language having all strings having exactly two 1’s or three 1’s not more than it.

0*10*10* + 0*10*10*10*

b) After generating the string from both regular expressions : ^ + 0(0+1)*+(0+1)*00(0+1)*= ^, 0, 00, 01,001,010,100,011,000,0011,1100……… ((0*1)*01*)* = ^,0,00,01,10,010,100,011,101,110,000,……………..

We can see that first RE cannot generate the string ‘10’ while this string can be generated by second RE. So they are not expressing the same language. Hence it is concluded that given Regular expressions are NOT equivalent. Question No. 2 Marks: 4

a) Give recursive definition for the language ODD, of strings defined over ∑={-,0,1,2,3,4,5,6,7,8,9}, b) Give recursive definition for the language of palindromes having odd length Solution: a) Step1: 1 is in ODD Step2: if x is in ODD, then x+2 and x-2 are also in ODD Step3: No Strings except those constructed above, are allowed to be in ODD b) Step1: a and b are in PALINDROME. Step2: if x is in PALINDROM then axa and bxb are also in PALINDROME Step3: No Strings except those constructed above, are allowed to be in PALINDROME

Question No. 3

Marks: 6

Three Finite Automata (FAs) have been given below:

FA1

FA2

FA3

Match the following Regular Expressions (RE’s) with corresponding Finite Automata (FA’s) given above. Also describe their languages (in English).

Regular Expression a(aa)*(^+a)b+b aa*b(aa*b)*

Finite Automaton (FA)

Language Description

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

Solution:

Regular Expression a(aa)*(^+a)b+b

Finite Automaton (FA) FA3

Language Description All strings in which “b” occurs only one time and that is only at the end of the string.

aa*b(aa*b)*

FA1

All strings which begins with “a” and ends at “b” and not containing the substring “bb”.

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

FA2

All strings having substring “ab”.

Question No. 4

Marks: 6

Build an FA over Σ={a, b} that accepts only those words that do not contain the substring “ba”. Also make transition table for that FA.

Solution: FA

Transition table corresponding to above FA

New States Old States q0q1+ q2 q3+ After Reading a q3 q2 q2 q3 After Reading b q1 q1 q2 q1

Assignment 2

Question No.1

Find the Regular Expression corresponding to the given FA. Show all steps. [Hint: FA to GTG a GTG to RE.]

Mark: 5

Solution:

Step1:

Step2: Eliminating loop from q1

Step3: Eliminating state q1

Step4: To connect the initial state to the final state by single transition edge, the above TG can be reduced to the following

Hence the Required RE is

((0+1)0*11*0 )* . (0+1)0*11*

Question No.2

Mark: 5

A student walks into a classroom and sees on the blackboard a diagram of a TG with two states that accepts only the string Λ. The student reverses the direction of exactly one edge, leaving all other edges and all labels and all final states (+’s) and start state (-) the same. The new TG accepts the language a*. What was the original TG?

Solution:

Original TG accepts only Λ

New TG accepts the language a*

Question No. 3

Determine RE corresponding to the following TG. Show all steps. [Hint: TG to GTG a GTG to RE.]

Mark: 10

Solution:

Step 1: By eliminating states 7,8,10,11

Step 2: By eliminating states 6

Step 3: By eliminating states 9 and 12

Step 4: By combining loops at state 3

Step 5: By eliminating states 2

Step 6:

By eliminating states 4

Step 7: By eliminating states 3

Hence the Required RE is ba(abba+aabb)*(b+Λ)ab

Assignment 3

Question No 1: Let r1= (a+b)*ab(a+b)*

Marks: 12

r2= (a*ba)*a*b

(The RE given in assignment was incorrect so it has been corrected now

According to the requirement of the question you had to work with FAs so mistake in RE will not effect your solution)

FA1 corresponding to r1

FA2 corresponding to r2

Using the FAs corresponding to r1 and r2, Build an FA corresponding to

a) r1+ r2 (Union of r1 and r2). b) r1r2 (Concatenation of r1 and r2). c) r1* (Closure of r1).

Note :You have to specify transition table and transition diagram for each part(a)(b)(c)

Solution: a) Transition table corresponding to required FA

Old States

New states after reading a b

z1 − ≡ ( x1 , y1 ) z2 ≡ ( x2 , y1 ) z3 + ≡ ( x1 , y2 ) z4 + ≡ ( x3 , y2 ) z5 ≡ ( x1 , y3 ) z6 + ≡ ( x3 , y3 ) z7 + ≡ ( x3 , y1 ) z8 ≡ ( x2 , y3 )

( x2 , y1 ) ≡ z2 ( x2 , y1 ) ≡ z2 ( x2 , y1 ) ≡ z2 ( x3 , y1 ) ≡ z7 ( x2 , y3 ) ≡ z8 ( x3 , y3 ) ≡ z6 ( x3 , y1 ) ≡ z7 ( x2 , y3 ) ≡ z8

( x1 , y2 ) ≡ z3 ( x3 , y2 ) ≡ z4 ( x1 , y3 ) ≡ z5 ( x3 , y3 ) ≡ z6 ( x1 , y3 ) ≡ z5 ( x3 , y3 ) ≡ z6 ( x3 , y2 ) ≡ z4 ( x3 , y3 ) ≡ z6

FA corresponding to r1+ r2

b) Transition table corresponding to required FA

Old States

New states after reading a b

z1 − ≡ x1 z2 ≡ x2 z3 ≡ ( x3 , y1 ) z4 + ≡ ( x3 , y1 , y2 ) z5 + ≡ ( x3 , y1 , y2 , y3 ) z6 ≡ ( x3 , y1 , y3 )

x2 ≡ z2 x2 ≡ z2 ( x3 , y1 ) ≡ z3 ( x3 , y1 ) = z3 ( x3 , y1 , y3 ) ≡ z6 ( x3 , y1 , y3 ) ≡ z6

x1 ≡ z1 ( x3 , y1 ) ≡ z3 ( x3 , y1 , y2 ) = z4 ( x3 , y1 , y2 , y3 ) ≡ z5 ( x3 , y1 , y2 , y3 ) ≡ z5 ( x3 , y1 , y2 , y3 ) ≡ z5

FA corresponding to r1r2

c) Transition table corresponding to required FA

Old States

New states after reading a b

Final z1 ± ≡ x1 Non-final z2 ≡ x1

x2 ≡ z3 x2 ≡ z3 x2 ≡ z3 ( x3 , x1 , x2 ) ≡ z5 ( x3 , x1 , x2 ) ≡ z5

x1 ≡ z2 x1 ≡ z2 ( x3 , x1 ) ≡ z4 ( x3 , x1 ) = z4 ( x3 , x1 ) = z4

z3 ≡ x2 z4 + ≡ ( x3 , x1 ) z5 + ≡ ( x3 , x1 , x2 )

FA corresponding to r1*

Question No 2:

Marks: 4

Convert the following NFA into FA.

Solution: Transition table corresponding to required FA

Old States

New states after reading a b

z1 ± = 0 z2 + ≡ (1, 2) z3 + ≡ (1, 2,3) z4 + ≡ (1,3)

(1, 2) ≡ z2 (1, 2,3) ≡ z3 (1, 2,3) ≡ z3 (1, 2,3) ≡ z3

Φ

(1,3) ≡ z4 (1,3) ≡ z4

Φ

FA corresponding to given NFA

Question No 3:

Marks: 4

Build an NFA equivalent to the FA* where

FA

Solution: NFA equivalent to the FA* where

Assignment 4

Question No 1:

Marks: 5

Let L be the language of strings defined over Σ= {0, 1} having odd no. of 1’s.Now Find Distinguishable and Indistinguishable strings by taking z as “1” belonging to Σ*.

Solution:

x 11000 00000 10010 10011 00111

y 10000 11111 00110 10000 10111

Distinguishable/Indistinguishable Distinguishable Distinguishable Indistinguishable Indistinguishable Distinguishable

Question No 2: Marks:10 Convert the following Moore machine to an equivalent Mealy machine:

a) Construct transition table for Mealy machine. b) Run the string “babaaba” on both machines and find the output. Solution: Mealy machine corresponding to Moore machine

a) Transition table for Mealy machine. input States Output q0 1 a Next State q2 Output 0 b Next State q1

q1 q2 q3

1 0 0

q2 q3 q3

0 1 0

q3 q2 q3

b) Run the string “babaaba” on both machines and find the output. Input States Mealy Moore 1 q0 b q1 0 0 a q2 1 1 b q2 1 1 a q3 0 0 a q3 0 0 b q3 0 0 a q3 0 0

Question No 3: Marks:5 Using De-Morgan’s law determine an FA corresponding to FA1∩FA2

FA1:

FA2:

Solution:

FA1c:

FA2c:

Transition table for FA1c U FA2c

New States After Reading Old states a b

z1 ± ≡ (x0,y0) z2 + ≡ (x1,y0) z3+ ≡ (x1,y1) z4+ ≡ (x0, y1) z5 ≡ (x0,y2) z6+ ≡ (x1,y2)

z2 ≡ (x1,y0) z1 ≡ (x0,y0) z5 ≡ (x0,y2) z6 ≡ (x1,y2) z6 ≡ (x1,y2) z5 ≡ (x0,y2)

z3 ≡ (x1,y1) z4 ≡ (x0,y1) z4 ≡ (x0,y1) z3 ≡ (x1,y1) z6 ≡ (x1,y2) z5 ≡ (x0,y2)

FA corresponding to FA1c U FA2c

FA corresponding to ( FA1c U FA2c)c = FA1 ∩ FA2

Assignment 5

Question No 1:

Marks: 5

Find the prefixes of Q in R where Q and R are languages give below:

Q={ ababa , aabbbbbbb,baabba , babbaaaaaa }

R={ aababa , bbaabba , bbaababa, aaaabbbbbbb, abbabbaaaaaa}

Solution:

Pref(Q in R)={a,b,aa,ab,bba, }

Question No. 2

Marks: 5

By marking the states, decide whether the following FA accepts any word or not?

Note: Show all steps

Solution:

Marking and processing state q0

Processing state q1

Processing state q3

Processing state q2

Since no new state is marked and the final state q4 is unmarked therefore, the given FA does not accept any word.

Question No. 3

Marks: 5

Describe the language (in English) generated by the following CFG:

S → XY X → aX | bX | Λ Y → baa | bab | bba | bbb

Solution:

The given CFG generates the language L = {w ∈ {a, b}*: length(w) ≥ 3 and third letter of w, from right is b.

Question No. 4

Marks: 5

Construct the CFG that generates the language L = {w ∈ {a, b}*: length(w) ≥ 2 and w begins with b and ends in aa or bb}.

Solution:

S → bXY|bb X → aX | bX | Λ Y → aa | bb

Assignment 6

Question:

Mark:5+5+5+5

Consider the following Context Free Grammar (CFG)

S → aY | Ybb | Y X→Λ|a Y → aXY | bb | XXa

a) b) c) d)

Is the CFG ambiguous, if Yes then justify your answer. Draw a Total Language Tree (TLT) for the given CFG. Convert the CFG into CNF. Build the PDA corresponding to the CFG (in CNF) of part (c).

Solution : a) The CFG is said to be ambiguous if there exists atleast one word of it’s language that can be generated by the different production trees. The word abb can be generated by the following three different trees

S ⇒ aY S ⇒ abb

S ⇒ Ybb S ⇒ XXabb S ⇒ Xabb S ⇒ abb

S⇒Y S ⇒ aXY S ⇒ aY S ⇒ abb

Hence it has been concluded that the given CFG is ambiguous.

b) Total Language Tree

We can see that Y is repeating it self so Tree is growing in recursive manner.

c) Converting CFG into CNF Remove the null production X →Λ.The new CFG, without null productions, is:

S → aY | Ybb | Y X →a

Y →aXY | aY | bb | XXa | Xa | a

The only unit production is S → Y, where the Y can be replaced with all Y’s non-unit productions (i.e. all of them).

The new CFG, without unit productions, is:

S → aY | Ybb | aXY | aY | bb | XXa | Xa | a X →a Y →aXY | aY | bb | XXa | Xa | a

Introduce the non-terminal A →a B →b

The new CFG, consisting of only solid non-terminals or one terminal is:

S → AY | YBB | AXY | AY | BB | XXA | XA | a X→a Y → AXY | AY | BB | XXA | XA | a A→a B→b

Shorten the strings of non-terminals to length 2.Create new, intermediate non-terminals to accomplish this.

C → BB D → XY E → XA

The new CFG, in CNF is:

S → AY | YC | AD | AY | BB | XE | XA | a X→a Y → AD | AY | BB | XE | XA | a A→a B→b C → BB D → XY E → XA

d) PDA corresponding to the CFG

- Log and Antilog Tables
- CS708 Lecture Handouts
- CS706 Lecture Handouts (pdf format)
- Al Misbah Al Munir Tehzeeb w Tehqiq Tafseer Ibne Kaseer 6
- Al Misbah Al Munir Tehzeeb w Tehqiq Tafseer Ibne Kaseer 5
- Al Misbah Al Munir Tehzeeb w Tehqiq Tafseer Ibne Kaseer 4
- Al Misbah Al Munir Tehzeeb w Tehqiq Tafseer Ibne Kaseer 3
- Al Misbah Al Munir Tehzeeb w Tehqiq Tafseer Ibne Kaseer 2
- Al Misbah Al Munir Tehzeeb w Tehqiq Tafseer Ibne Kaseer 1
- Longest Common Sub-sequence & Optimal Binary Search Tree
- Chain Matrix Multiplication and 0/1 Knapsack
- Differential Equations Solved Examples
- Convolution Theorem Solved Example
- Combined Handouts CS702 (PDF format)
- Combined Handouts CS702 (WORD format)
- Laplace
- Convolution Theorem
- Critical Points Differential Equation
- Software Engineering I - Solved Assignments - Semester Spring 2010
- Differential Equations - Solved Assignments - Semester Summer 2007
- Differential Equations - Solved Assignments - Semester Spring 2008
- Differential Equations - Solved Assignments - Semester Spring 2007
- Differential Equations - Solved Assignments - Semester Spring 2006
- Differential Equations - Solved Assignments - Semester Spring 2005
- Differential Equations - Solved Assignments - Semester Spring 2004

Sign up to vote on this title

UsefulNot usefulTheory of Automata - Solved Assignments - Semester Spring 2010

Theory of Automata - Solved Assignments - Semester Spring 2010

- Chapter 5 - Finite Automata
- Theory of Automata by Cohen
- Automata Questions
- Chapter 5-Computer Theory BY Danial I. A Cohen
- -Chapter 3-Danial I. A Cohen-Computer Theory
- Daniel I. A. Cohen - Introduction to Computer Theory - 2nd Edition - Chapter 2
- Solution-Introduction+to+Automata+Theory
- COS201 Chapter 4
- Assignment 2Sou
- Solution Manual
- 2 - Recursive Definition
- Chapter 4-Computer Theory BY Danial I. A Cohen
- Solution_Manual Introduction to the Theory of Computation Sipser
- Automata - Hopcroft(Solutions)
- COS2601 - WikiStudent, Unisa
- Chapter1-2-3
- Solution to Peter Linz
- To c Questions
- 1 - Language
- Introduction to Computer Theory by Daniel I. a. Cohen - Second Edition
- r05310501 Formal Languages and Automata Theory
- Automata Theory Problems and Exercises
- Moore & Mealy Machine
- 8086 Masm Programs
- A 2
- 2cth(2)
- Solutions Peter Linz Automata
- Introduction to Computer Theory by Daniel I a Cohen - 5 Star Book Review
- Solution Manual for Data Communications and Networking by Behrouz Forouzan
- Solution Manual to Third Edition AI
- Theory of Automata - Solved Assignments - Semester Spring 2010