0% found this document useful (0 votes)
75 views9 pages

Kokkk

The document describes the steps to construct a Turing machine that accepts the language L = {a^nb^nc^n | n ≥ 1}. It involves the following steps: 1) Mark 'a' as 'X' and move to the first unmarked 'b' while passing other symbols 2) Mark 'b' as 'Y' and move to the first unmarked 'c' while passing other symbols 3) Mark 'c' as 'Z' and move back to the first 'X' while passing other symbols 4) Repeat the process until all 'a', 'b' and 'c' are checked for equality 5) Enter an accepting state if the strings are equal,

Uploaded by

halewat Abebe
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)
75 views9 pages

Kokkk

The document describes the steps to construct a Turing machine that accepts the language L = {a^nb^nc^n | n ≥ 1}. It involves the following steps: 1) Mark 'a' as 'X' and move to the first unmarked 'b' while passing other symbols 2) Mark 'b' as 'Y' and move to the first unmarked 'c' while passing other symbols 3) Mark 'c' as 'Z' and move back to the first 'X' while passing other symbols 4) Repeat the process until all 'a', 'b' and 'c' are checked for equality 5) Enter an accepting state if the strings are equal,

Uploaded by

halewat Abebe
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/ 9

6. Construct a PushDown Automata (PDA) accepting L= {a n b 3n | m, n ≥1}.

Q1 Q2 Q1
Q3
b,a; λ λ,z; λ

λ,z;z

a,z;aaaz b,a; λ

a,aaa ;aaaa

7. Construct an NPDA corresponding to the grammar

S → aABB|aAA,

A → aBB|b,

B → bBB|A

Solution;

,B;A

b,B;BB

b,A;

,z;sz ,z;
Q1 Q21 Q31

a,S;ABB

a,S;AA

a,A;BB

8. Find a context-free grammar that generates the language accepted by the NPDA

M = ({q0, q1} , {a, b} , {A, z} , δ, q0, z, {q1}), with transitions


δ (q0, a, z) = {(q0, Az)} ,

δ (q0, b, A) = {(q0, AA)} ,

δ (q0, a, A) = {(q1, λ)}

solution:

v={M,[q0Aq0],[q0Aq1],[q1Aq0],[q1Aq1], [q0zq0],[q0zq1],[q1zq0],[q1zq1]}

and q1 is final state

1, δ (q0, a, z) = {(q0, Az)} ,2^2=4

[q0,z,q0]=a[q0,A,q0][q0,z,q0] eliminated

[q0,z,q0]=a[q0,A,q1][q1,z,q0] eliminated

[q0,z,q1]=a[q0,A,q0][q0,z,q1] eliminated

[q0,z,q1]=a[q0,A,q1][q1,z,q1] X=aYZ

2, δ (q0, b, A) = {(q0, AA)} ,2^2=4

[q0,A,q0]=b[q0,A,q0][q0,A,q0] eliminated

[q0,A,q0]=b[q0,A,q1][q1,A,q0] eliminated

[q0,A,q1]=b[q0,A,q0][q0,A,q1] eliminated

[q0,A,q1]=b[q0,A,q1][q1,A,q1] Y=bkF

3, δ (q0, a, A) = {(q1, λ)},2^0=1

[q0,A,q1]=a Y=a

So ,the grammer is

X=aYZ

Y=bkF

Y=a
9. Construct a Turing machine that accepts the language L ={a^nb^nc^n,n>0?}

Step 1-2

Input is given as "aaabbbccc" (scan string from left to right)

Mark 'a' as 'X' and move one step right

Reach unmarked 'b' and pass every 'a' and 'Y'(in case) on the way to 'b'

Step 3-4

Mark 'b' as 'Y' and move one step right

Reach unmarked 'c' and pass every 'b' and 'Z'(in case) on the way to 'c'

Mark 'c' as 'Z' and move one step left cause now we have to repeat process

Reach unmarked 'X' and pass every 'Z', 'b', 'Y', 'a' on the way to 'X'

Move to 'a' and repeat the process

Step 5-9

Step 1-4 are repeated

Step 10

When TAPE header reaches 'X' and next symbol is 'Y' that means 'a's are finished

Check for 'b's and 'c's by going till BLANK(in right) and passing 'Y' and 'Z' on the way

If no 'b' and 'c' are not found that means string is accepted

State Transition Diagram

We have designed state transition diagram for anbncn | n ≥ 1 as follows:

Following Steps:

a. Mark 'a' with 'X' and move towards unmarked 'b'

b. Move towards unmarked 'b' by passing all 'a's

c. To move towards unmarked 'b' also pass all 'Y's if exist


Following Steps:

a. Mark 'b' with 'Y' and move towards unmarked 'c'

b. Move towards unmarked 'c' by passing all 'b's

c. To move towards unmarked 'c' also pass all 'Z's if exist

Following Steps:

a. Mark 'c' with 'Z' and move towards first 'X' (in left)

b. Move towards first 'X' by passing all 'Z's, 'b's, 'Y's and 'a's

c. When 'X' is reached just move one step right by doing nothing.
To check all the 'a's, 'b's and 'c's are over add loops for checking 'Y' and 'Z' after "we get 'X' followed by
'Y'"

To reach final state(qf) just replace BLANK with BLANK and move either direction

10. Design a Turing machine that accepts the language L = {ww : w ∈ {a, b}+}
Step-1:

If the symbol is 0 replace it by X and move right

If the symbol is 1 replace it by Y and move right,

Go to state Q1 and step 2

———————————————

If the symbol is X replace it by X and move left or

If the symbol is Y replace it by Y and move left,

Go to state Q4 and step 5

Step-2:

If the symbol is 0 replace it by 0 and move right, remain on the same state

If the symbol is 1 replace it by 1 and move right, remain on the same state

———————————————

If the symbol is X replace it by X and move left or

If the symbol is Y replace it by Y and move left or

If the symbol is $ replace it by $ and move left, Go to state Q2 and step 3

Step-3:

If symbol is 0 replace it by X and move left, or

If symbol is 1 replace it by Y and move left,

Go to state Q3 and step 4


Step-4:

If the symbol is 0 replace it by 0 and move left, remain on the same state

If the symbol is 1 replace it by 1 and move left, remain on the same state

———————————————

If the symbol is X replace it by X and move right or

If the symbol is Y replace it by Y and move right,

Go to state Q0 and step 1

Step-5:

If symbol is X replace it by X and move left or

If symbol is Y replace it by Y and move left

Go to state Q4 and step 6

Step-6:

If symbol is X replace it by 0 and move left, remain on same state

If symbol is Y replace it by 1 and move left, remain on same state

–––––––––—–––––––––—

If symbol is $ replace it by $ and move right

Go to state Q4 and step 7

Step-7:

If symbol is 0 replace it by X and move right, go to state Q6 and step 8


If symbol is 1 replace it by Y and move right, go to state Q7 and step 9

–––––––––—–––––––––—

If symbol is B replace it by B and move left, STRING ACCEPTED, GO TO FINAL STATE Q9

Step-8:

If symbol is 0 replace it by 0 and move right, remain on same state

If symbol is 1 replace it by 1 and move right, remain on same state

If symbol is B replace it by B and move right, remain on same state

–—––––––––––––––––––

If symbol is X replace it by B and move left

Go to state Q8 and step 10

Step-9:

If symbol is 0 replace it by 0 and move right, remain on same state

If symbol is 1 replace it by 1 and move right, remain on same state

If symbol is B replace it by B and move right, remain on same state

–—––––––––––––––––––

If symbol is Y replace it by B and move left

Go to state Q8 and step 10


Step-10:

If symbol is 0 replace it by 0 and move left, remain on same state

If symbol is 1 replace it by 1 and move left, remain on same state

If symbol is B replace it by B and move left, remain on same state

–—––––––––––––––––––

If symbol is Y replace it by Y and move right or

If symbol is X replace it by X and move right

Go to state Q5 and step 7

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy