homework4

# homework4 - the stack The PDA will then test at the end of...

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

Homework #4 Solutions. 2.5 a. b. c. d.

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

View Full Document
e. f. 2.6 b Three cases, more a’s than b’s, more b’s than a’s, and some a after some b are all in this language. These descriptions overlap, creating an ambiguous language. A Æ B| D | F B Æ C b C a C C Æ aC | bC | ε D Æ E a E E Æ EE | aEb | bEa | a | ε F Æ G b G G Æ GG | aGb | bGa | b | ε
d. Will come out later today. 2.7 b From a single start state, run an epsilon transition to two options. The case for a “b” somewhere before an “a” is easily solved in classic FSA notation, looping through some number of a’s, then transitioning to another state on a b, and lastly an accepting state on receiving another “a”. The other “counting” case will push onto the stack an “a” if there isn’t a “b” on the top of the stack, in which case it will instead pop that “b”. Likewise, it will push a “b” on top of the stack if there isn’t an “a”, otherwise popping said “a” from

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: the stack. The PDA will then test at the end of the input if the stack is not empty (\$) and will accept. 2.7 d Will also come out later today… 2.14 A Æ BAB | B | ε B Æ 00 | ε Add a new start state S Æ A A Æ BAB | B | ε B Æ 00 | ε Remove A Æ ε S Æ A | ε A Æ BAB | B B Æ 00 | ε Remove B Æ ε S Æ A | ε A Æ BAB | AB | BA | B B Æ 00 Remove A Æ B S Æ A | ε A Æ BAB | AB | BA | 00 B Æ 00 Convert to proper form S Æ A | ε A Æ BC | AB | BA | B B Æ 00 C Æ AB 2.27 a. If condition then <STMT> else <STMT> <ASSIGN> if condition then if condition then A:= 1 else A:= 1 <ASSIGN> <STMT> <STMT> <STMT> If condition then <STMT> <STMT> <ASSIGN> <ASSIGN> <STMT> <STMT> If condition then <STMT> <STMT> If condition then <STMT> else <STMT> <STMT> b. Stmt Æ <Assign> | <MIF> | <UIF> MIF Æ if condition then <MIF> else <MIF> | Stmt UIF Æ if condition then <Stmt> | if condition then <MIF> else <UIF> Assign Æ A := 1...
View Full Document

{[ snackBarMessage ]}

### Page1 / 4

homework4 - the stack The PDA will then test at the end of...

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

View Full Document
Ask a homework question - tutors are online