Home14UnrestGrammars

# Home14UnrestGrammars - CS 341 Automata Theory Elaine Rich...

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

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: CS 341 Automata Theory Elaine Rich Homework 14 Due Friday, Dec.8 at 11:59 pm 1) Construct unrestricted grammars that generate each of the following languages L : a) { ww R w : w { a , b }*}. b) { a n b m c n + m : n , m > 0}. c) { a n b m c nm : n , m > 0}. 2) Construct an unrestricted grammar to compute the following function: f : {a, b} + { a , b }* f ( s ) = if | s | is even then s if | s | is odd then s with the middle character chopped out (Hint: The answer to this one is fairly long, but it's not very complex. Think about how you would use a Turing Machine to solve this problem.) CS 341 Automata Theory Elaine Rich Homework 14 Answers 1) Construct unrestricted grammars that generate each of the following languages: a) L = { ww R w : w { a , b }*} S S S 1 # S 1 a S 1 a First generate wTw R # S 1 b S 1 b S 1 T Take each character of w R , starting at the left. Make a copy of it and slide it to the right of the # to create the second w. Use 1 for a and 2 for b. Ta T 1 A Well move A for a, B for b. And well transform each character Tb T 2 B of w R as it is considered: a will be 1, b will be 2. These two rules will handle the first such character. 1 a 1 1 A These next four will do this for characters 2 through n of w R . 1 b 1 2 B 2 a 2 1 A 2 b 2 2 B A a a A Push As and Bs to the right until they hit #. A b b A B b b B B a a B A # # a Jump across # B # # b 1 # # a Once all of w R has been converted to 1s and 2s (i.e., its all 2 # # b been copied), push # leftward converting 1s back to as and 2s to bs....
View Full Document

## This note was uploaded on 12/03/2009 for the course CS 341 taught by Professor Rich during the Fall '08 term at University of Texas at Austin.

### Page1 / 5

Home14UnrestGrammars - CS 341 Automata Theory Elaine Rich...

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

View Full Document
Ask a homework question - tutors are online