0% found this document useful (0 votes)
21 views2 pages

HW 5 Solutions

The document contains solutions for a homework assignment involving the design of pushdown automata (PDA) for various languages. Each problem specifies a language and the corresponding PDA design, indicating whether it accepts by final state or empty stack. The document also includes a conversion of a grammar into a PDA and a derivation for a specific string using Chomsky's algorithm.

Uploaded by

Erik Brown
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

HW 5 Solutions

The document contains solutions for a homework assignment involving the design of pushdown automata (PDA) for various languages. Each problem specifies a language and the corresponding PDA design, indicating whether it accepts by final state or empty stack. The document also includes a conversion of a grammar into a PDA and a derivation for a specific string using Chomsky's algorithm.

Uploaded by

Erik Brown
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CS 383

HW 5 Solutions

1. Design a PDA to accept the strings in (0+1)* such that no prefix has more 1’s than 0’s.
01001011001 is a string in this language. Say whether your PDA accepts by final state or empty
stack.
1,0|
0,0|00
0,Z0|0Z0 Accepts by final state.

,X|Z0X ,Z0|
S T
,0|

2. Design a PDA to accept {aibjck | i=j or j=k}. Say whether this accepts by final state or empty stack.
a,X|X b,a| c,Z |Z 0 0
,Z0|Z,X|X
0 ,Z0|Z0
,Z0|Z0
UX V
TX ,Z0|
,X|Z0X
S
a,Z0|Z0 b,X|X c,b| W
,Z0|Z0 ,Z0|Z0
,X|X ,X|X ,Z0|
X YX ZX
S

Accepts by empty stack


3. Design a PDA to accept {0n1m | n <= m <= 2n}

0,X|00X Accepts by empty stack


0,X|0X
1,0|
,X|Z0X ,X|X ,Z0|
S TX U

4. Convert the following grammar into a PDA that accepts by empty stack.
S => 0S1 | A
A => 1A0 | S | 
1,1|
0,0|
,S|0S1
,S|A
,A|1A0
,A|S
,A|
,X|SX
Q

5. Here is a PDA that accepts strings in (0+1)* with the same number of 0’s and 1’s. This PDA
accepts by empty stack. Chomsky’s algorithm gives a grammar equivalent to this PDA, with
grammar symbols of the form [pXq]. Give a derivation in this grammar for the string 0101.

1,1|11
1,0|
1,Z0|1Z0 Derivation:
0,0|00 Start => [PZ0Q]
0,1| => 0[P0P][PZ0Q]
0,Z0|0Z0 => 01[PZ0Q]
=> 010[P0P][PZ0Q]
=> 0101[PZ0Q]
=> 0101
,Z0|
P Q

You might also like