You are on page 1of 4

Assignment 4

1)Construct a PDA equivalent to the following grammar:


E → E + T| T
T→T*F|F
F→(E)|a

Ans- Here is the PDA equivalent to the given grammar:

States: q0, q1, q2, q3, q4, q5, q6, q7, q8, q9

Start state: q0

Accept state: q9

Alphabet: {(, ), a, +, *}

Stack alphabet: {Z0, E, T, F, +, *}

Transitions:

1. (q0, ε, ε) → (q1, Z0)

2. (q1, ε, ε) → (q2, E)

3. (q2, ε, ε) → (q3, T)

4. (q2, ε, ε) → (q9, ε) [Accept state]

5. (q3, ε, ε) → (q4, F)

6. (q4, ε, ε) → (q9, ε) [Accept state]

7. (q4, +, ε) → (q5, +)

8. (q5, ε, ε) → (q6, T)

9. (q6, ε, ε) → (q7, F)

10. (q7, ε, ε) → (q3, T)

11. (q3, *, ε) → (q8, *)

12. (q8, ε, ε) → (q4, F)


Assignment 4

13. (q4, ), ε) → (q9, ε) [Accept state]

14. (q4, a, ε) → (q9, ε) [Accept state]

15. (qi, a, a) → (qi+1, ε) [for i = 1 to 8]

16. (qi, +, +) → (qi+1, ε) [for i = 1 to 8]

17. (qi, *, *) → (qi+1, ε) [for i = 1 to 8]

Note:

- Z0 is the initial stack symbol.


- qi denotes the current state, and qi+1 denotes the next state.
- The transitions from q1 to q4 handle the production E → T and T → F.
- The transitions from q5 to q7 handle the production E → E + T.
- The transitions from q3 to q8 handle the production T → T * F.
- The transitions from q4 to q9 handle the production F → ( E ) and F → a.

2)Design a PDA to accept the following language for: L={ aib j c k | j = i+k and i, j, k > 0 }

Answer: A PDA is as follows:


Assignment 4
Assignment 4

You might also like