2

I'm trying to write a pda pushdown automata that accept a^2n b^n, n>0 but I'm not sure if the last part is correct

(p0, a, z0) = (p0, az0)
(p0, a, a) = (p0, aa)
(p0, b, a) = (p1, λ)
(p1, λ, b) = (p2, λ)   <=
(p2, 0, b) = (p1, λ)  <=
(p2, λ, z0) = (p3, λ)  <=
userNew
  • 81
  • 1
  • 3
  • 10

3 Answers3

0

As far as your answer is concerned, in your first two steps you are pushing a's in only one step. With the current design the machine would accept aaabb which is not in the form a^2nb^n. So it's better to divide it in two states separately. According to me the right answer might be something like:

  1. (p0, a, z0) = (p0, az0)
  2. (p0, a, a) = (p1, aa)
  3. (p1, a, a) = (p0, aa)
  4. (p1, b, a) = (p2, λ)
0

Deterministic push down automata for a^2nb^n n>=0
Bypass altetnate a's and push rest of a's

flipchart capture

user1859022
  • 2,585
  • 1
  • 21
  • 33
Vishal
  • 11
  • This PDA will also work for a^(2n - 1)b^n. To correct this the first state and can bypass a's and the in the second one you can push a's. – Vardan Agarwal Nov 03 '19 at 06:15
0

q0 is initial state and qf is final is state; ^ is for null:

Q(q0,a,z)=Q(q1,z)
Q(q0,a,a)=Q(q1,aa)
Q(q0,b,a)=Q(q0,^)
Q(q0,^,z)=Q(qf,z)
Q(q1,a,z)=Q(q2,az)
Q(q1,a,a)=Q(q2,a,a)
Q(q2,a,a)=Q(q0,az)
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
vivek
  • 1