{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cs381-fall02-prelim2-solutions

# cs381-fall02-prelim2-solutions - CS381 Fall 2002 Second Mid...

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

CS381 Second Mid Term Friday Nov 8, 2002 Fall 2002 Olin 155 9:05-9:55 This is a 50-minute in class closed book exam. All questions are straightforward and you should have no trouble doing them. Please show all work and write legibly. Thank you. 1 . (a) Give a context-free grammar for the language } ' ' * ) ( | { s b and s a of number equal an has x and b a x x + (b) For each variable in the grammar describe the strings that can be generated from the variable by a statement such as s b and s a of number equal an has x iff x S ' ' Solution : bSa aSb SS S | | | ε s b and s a of number equal an has x iff x S ' ' Clearly any string generated has an equal number of a’s and b’s since the righthand side of each production has an equal number of a’s and b’s. Thus, it remains to show only that all such strings are generated. Let x have an equal number of a’s and b’s. If x=ε then clearly x is generated. Assume all x with equal number of a’s and b’s and |x|<n are generated. Let x be of length n. Write k x x x x 2 1 =

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.

{[ snackBarMessage ]}

### Page1 / 2

cs381-fall02-prelim2-solutions - CS381 Fall 2002 Second Mid...

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

View Full Document
Ask a homework question - tutors are online