0

I'm stuck building the transition functions for this automaton.

I suppose I should stack a 1 for each a and unstack it for each b

The number of c's equals the number of ab pairs, so I think I should stack a 0 for each b I encounter. Thing is: how do I unstack 1s and add 0s at the same time?

Ewan Todd
  • 7,315
  • 26
  • 33
andandandand
  • 21,946
  • 60
  • 170
  • 271
  • 1
    Refresh my memory: Do pushdown automata support lamda transitions? – Anon. Jan 17 '10 at 20:15
  • @Mark Byers: yes, it is. @Anon.: I don't know! But I'm sure they can be non-deterministic and transition to two different states using the same symbol. – andandandand Jan 17 '10 at 20:22

1 Answers1

5

Don't push a 0 onto the stack each time you encounter a b. Instead, push a 0 onto the stack each time you encounter a b and the stack is empty or the top of the stack is a 0.

So, using your nomenclature for aabbabcc:

read a push 1
read a push 1
read b pop 1
read b pop 1
stack is empty so push 0
read a push 1
read b pop 1 
top of stack is 0 so push 0
read c pop 0
read c pop 0

Stack is empty so we accept this string.

jason
  • 236,483
  • 35
  • 423
  • 525