hw5_solution

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

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
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

Page1 / 8

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online