How would I write a pda for 0^m 1^n, where |m| >= |n|; the number of 0’s is greater than or equal to the number of 1’s?
I was thinking of:
- if you see a 1 or 0, push it on to the stack
- if you see another 0 or a bunch of 0’s, push it on to the stack
- if you see a 1, push it on to the stack
- if you see another 1 after that, pop it off of the stack
But, I don’t think this is right. Can someone help please?
If I understand the assignment correctly, then you are making this way to complicated. 0^m 1^n means a bunch of 0’s followed by an bunch of 1’s, but there is no legal string with a 0 after you have seen a 1. First you put a sign on the stack so you know when it’s empty (ususally the #). After that you basically need to count the 0’s (push them onto the stack) and when you see a 1, pop from the stack. When the input has finished you check whether the stack is you have any 0´s or the symbol that you put on the stack in the beginning.