HM2-Chapters2-4-Answers

HM2-Chapters2-4-Answers - CS 341 Homework 2 Answers Chapter...

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

View Full Document Right Arrow Icon
CS 341 Homework 2 Answers Chapter 2 1) Consider the language L = { 1 n 2 n : n > 0}. Is the string 122 in L ? No. Every string in L must have the same number of 1 ’s as 2 ’s. 2) Let L 1 = { a n b n : n > 0}. Let L 2 = { c n : n > 0}. For each of the following strings, state whether or not it is an element of L 1 L 2 : a) ε . No. b) aabbcc . Yes. c) abbcc . No. d) aabbcccc . Yes. 3) Let L 1 = { peach , apple , cherry } and L 2 = { pie , cobbler , ε }. List the elements of L 1 L 2 in lexicographic order. apple , peach , cherry , applepie , peachpie , cherrypie , applecobbler , peachcobbler , cherrycobbler (We list the items shortest first. Within a given length, we list the items alphabetically.) 4) Let L = { w { a , b }* : | w | 3 0}. List the first six elements in a lexicographic enumeration of L . ε , aaa , aab , aba , abb , baa 5) Consider the language L of all strings drawn from the alphabet { a , b } with at least two different substrings of length 2. a) Describe L by writing a sentence of the form L = { w Σ * : P ( w )}, where Σ is a set of symbols and P is a first-order logic formula. You may use the function | s | to return the length of s . You may use all the standard relational symbols (e.g., =, , <, etc.), plus the predicate Substr ( s , t ), which is True iff s is a substring of t . L = { w { a , b }* : 5 x , y ( x y | x | = 2 | y | = 2 Substr ( x , w ) Substr ( y , w ))}. b) List the first six elements of a lexicographic enumeration of L . aab , aba , abb , baa , bab , bba 6) For each of the following languages L , give a simple English description of L . Show two strings that are in L and two that are not (unless there are fewer than two strings in L or two not in L , in which case show as many as possible). a) L = { w { a , b }* : exactly one prefix of w ends in a }. L is the set of strings composed of zero or more b ’s and a single a . a , bba and bbab are in L . bbb and aaa are not. b) L = { w { a , b }* : all prefixes of w end in a }.
Background image of page 1

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

View Full DocumentRight Arrow Icon
L = , since ε is a prefix of every string and it doesn’t end in a . So all strings are not in L , including a and aa . c)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the 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.

Page1 / 4

HM2-Chapters2-4-Answers - CS 341 Homework 2 Answers Chapter...

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

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