Construct the NPDA for the language: L={w:w∈{a,b}^*,the number of a' s is at least the number of b' s }
Asked
Active
Viewed 1,007 times
2 Answers
0
Our strategy can be this:
- input a, stack a/Z: push a
- input a, stack b: pop
- input b, stack a: pop
- input b, stack b/Z: push b
- accept if no additional input and stack a/Z
Why does this work? If we have more a than b, we end up with a on the stack. If the numbers of a and b are the same, we end up with Z on the stack. If there are more b than a, we end up with b on the stack. So we accept either a or Z on top when the input is exhausted.
q e s q' s'
q0 a Z q0 aZ
q0 a a q0 aa
q0 a b q0 -
q0 b Z q0 bZ
q0 b a q0 -
q0 b b q0 bb
q0 - a q1 a
q0 - Z q1 Z
q1 - a q1 -
This PDA ends in q1 with an empty stack if the input string has at least as many a as b.

Patrick87
- 27,682
- 3
- 38
- 73
0
L = {w:w∈{a,b}^*}
So here in this case the Stack would start with z and then afterwards pushing the symbol 'a' and then popping the symbol 'b'.
And, also the minimal string would be string 'ab';
So the transitions function in this case would be as follows:
δ(q0, a, z) = (q0, az) => a,z/az
δ(q0, b, a) = (q1, ε) => b,a/ε
δ(q1, ε, z) = (q2, z) => ε/z
Here the state q0 would be the start state and state q2 would be the final state.

Deep Patel
- 1
- 1