hw5_solution

# hw5_solution - CS150 Homework 5 Due 6/7 Problem 1(Exercise...

This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS150 Homework 5 Due 6/7 Problem 1. (Exercise 6.3.2, 10 points) Convert the grammar S → aAA A → aS | bS | a to a PDA that accepts the same language by empty stack. PDA ( { q } , { a,b } , { S,A,a,b } ,δ,q,S ) where δ ( q,a,a ) = { ( q,² ) } δ ( q,b,b ) = { ( q,² ) } δ ( q,²,S ) = { ( q,aAA ) } δ ( q,²,A ) = { ( q,aS ) , ( q,bS ) , ( q,a ) } 1 Problem 2. (Exercise 6.3.4, 10 points) Convert the PDA of Exercise 6.1.1 to a context-free grammar. Exercise 6.1.1: The PDA P = ( { q,p } , { , 1 } , { Z ,X } ,δ,q,Z , { p } ) has the following transition function: 1. δ ( q, ,Z ) = { ( q,XZ ) } . 2. δ ( q, ,X ) = { ( q,XX ) } . 3. δ ( q, 1 ,X ) = { ( q,X ) } . 4. δ ( q,²,X ) = { ( p,² ) } . 5. δ ( p,²,X ) = { ( p,² ) } . 6. δ ( p, 1 ,X ) = { ( p,XX ) } . 7. δ ( p, 1 ,Z ) = { ( p,² ) } . Starting from the initial ID ( q,w,Z ). S → [ qZq ] | [ qZp ] The following four productions come from rule (1). [ qZq ] → 0[ qXq ][ qZq ] [ qZq ] → 0[ qXp ][ pZq ] [ qZp ] → 0[ qXq ][ qZp ] [ qZp ] → 0[ qXp ][ pZp ] The following four productions come from rule (2). [ qXq ] → 0[ qXq ][ qXq ] [ qXq ] → 0[ qXp ][ pXq ] [ qXp ] → 0[ qXq ][ qXp ] [ qXp ] → 0[ qXp ][ pXp ] 2 The following two productions come from rule (3). [ qXq ] → 1[ qXq ] [ qXp ] → 1[ qXp ] The following production comes from rule (4)....
View Full Document

{[ snackBarMessage ]}

### Page1 / 8

hw5_solution - CS150 Homework 5 Due 6/7 Problem 1(Exercise...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online