flac-hw7 - <if stmt> |<if stmt>...

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

View Full Document Right Arrow Icon
FLAC Assignment 7 Exercise 1 Give a Turing machine with at most 12 states that doubles a number in unary representation. You will lose points if you use extra states. It should be clear your solution is correct; give explanation if necessary. Exercise 2 (a) Convert the following CFG into Chomsky Normal Form. Write down your steps. S a A a | b B b | ± A C | a B C | b C CDA | ± D A | B | ab (b) Use Younger’s Algorithm to to decide whether “ababa” is in the language. Write down the steps. Exercise 3 We already know { a n b n c n | n 0 } is not a context free language. Give a Turing machine that decides this language. Page 1
Background image of page 1

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

View Full Document Right Arrow Icon
Exercise 4 We know following grammar is ambiguous. Please give some string in the language and show such that it has two different parse trees. Here, <stmt> is the start symbol and terminals are: else, basic stmt, for clause, if, boolexpr, then, blk, compound. <stmt> <uncond stmt> | <cond stmt> <uncond stmt> basic-stmt | <for stmt> | blk | compound <for stmt> for clause <stmt> <cond stmt>
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: <if stmt> | <if stmt> else <stmt> <if stmt> → <if clause> <uncond stmt> <if clause> → if boolexpr then Exercise 5 In class we introduced a type of Turing Machine whose tape is two-way infinite, which means the machine can keep moving left or right indefinitely. Also the action that the machine can take is one of { L,R,N } . In the book, the definition is slightly different. The tape of the Turing Machine is one-way infinite, which means there is a leftmost square of the tape and the machine cannot move left when at that position. In addition, the action the machine can take is one of { L,R } . You task is to prove that a Turing Machine of the type defined in the textbook can simulate a Turing Machine of the type defined in class. Exercise 6 (Bonus) Prove that any context-free language over alphabet size 1, for example Σ = { 1 } , is also regular language. Page 2...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

flac-hw7 - <if stmt> |<if stmt>...

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

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