Question text is in black, my answers in blue.

**Question 1.1, posted 7 February:**In Exercise 1.13, by a "pair" of 1's, do they mean a pair of adjacent 1's? That is, I know that 1001 would be accepted for sure, but would 1001001? Each adjacent pair of 1's there is separated by an even number of symbols, but the first and last 1 are separated by an odd number.Because the problem says "by an odd number of symbols" rather than "by an odd number of 0's", and it doesn't use the word "adjacent", I don't think he means "adjacent". So in your example, the first and last 1 do form "a pair of 1's", and they are separated by five symbols, so the string 1001001 should not be accepted. In regular expressions, then, you want the complement of Σ

^{*}1(ΣΣ)^{*}Σ1Σ^{*}rather than the complement of Σ^{*}1(00)^{*}01Σ^{*}.Both those regular expressions lead to NFA's with four states, though the first NFA I constructed for each had five states. When I convert those NFA's to DFA's, I get a DFA that can be minimized to five states in the case of Σ

^{*}1(ΣΣ)^{*}Σ1Σ^{*}, but one that can be minimized to four states in the case of Σ^{*}1(00)^{*}01Σ^{*}. This is further evidence that the former case is the one that Mike meant.**Question 2, posted 12 February**I'm confused about Exercise 1.22 -- normally the whole point of having a two-character delimiter is so that you can use one character or the other in the delimiter, but not actually close the comment unless you use both in the right order. But the question says "comments themselves are written with only the symbols a and b". Does that mean the regular expression is just "/#(a∪b)^{*}#/"?You're rght that the question appears to be saying that, but as you say it makes much more sense if you could have /'s and #'s in the comment as long as you don't have a #/ combination. I checked the answer guide the publisher gave me, and the answer there confirms that the statement you quote is misleading, and that a string in C may have /'s or #'s in the middle. Under this interpretation, it makes more sense to design the DFA first, as the order of parts (a) and (b) suggests. (Under the other interpretation, the regular expression is easier.)

**Question 3, posted 12 February**Can you give a hint on the extra credit problem, 1.57?Sure. Because A is a regular language there exists a DFA M such that L(M) = A. When you read a string w, you need to know two things: (1) into what state does w take M, starting from the start state? (2) what possible state transitions, from what state p to what state q, could occur in M when reading any string of the same length as w?

If you know both these things, you can determine whether w is in the first-half-of-A language. So the problem is to compute these two things with a finite-state machine that reads w from left to right.

**Question 4, posted 12 February**I'm not sure I get Problem 1.37 yet, but it reminds me of the trick to tell whether a decimal number is divisible by 3 or 9 -- you add up the digits mod 3 or mod 9 and see whether you get 0. But this doesn't work for other bases -- am I on the right track?Basically, yes -- the principle underlying that trick is that you can read the number left to right and determine, after reading each digit, the mod 9 residue of the number you have seen so far. If you have read a decimal number n and you then see a new digit d, the new decimal number is just 10n + d. Mod 3 or mod 9, 10n + d is congruent to n + d, so you can just add the new digit to the residue you have calculated to get the new residue. With another base or another modulus, you will usually have a somewhat more complicated task to compute the new residue.

**Question 5, posted 14 February**I'm still not clear on the perfect shuffle language of Problem 1.41. Could you give me some examples? What if A were {a,b,c} and B were {1,2,3}?Well, with that language every string in A and every string in B has length 1. If S is the perfect shuffle language, every string in S is made up from an A string and a B string, so it has to have length 2. The set of possibilities is {a1,a2,a3,b1,b2,b3,c1,c2,c3}.

The general rule is that S is the set of all strings w such that (1) w has even length, (2) the odd-numbered letters of w form a string in A, and (3) the even-numbered letters of w form a string in B. (Here I'm following Mike rather than Java and numbering the letters of w from 1 through n rather than starting at 0.)

Suppose A were (a∪b)

^{*}and B were (c∪d)^{*}. Then S would be all strings of even length where every odd-numbered letter is a or b and every even-numbered letter is c or d, so S = ((a∪b)(c∪d))^{*}.Here's a trickier one. Suppose A is the set of all even-length strings, (ΣΣ)

^{*}, and B is the set of all odd-length strings, (ΣΣ)^{*}Σ. What is S? It's the empty language, because we can never have a string in A and a string in B of the same length.You might find it helpful to design a DFA for the language ((a∪b)(c∪d))

^{*}and see what it has to do with DFA's for the corresponding languages (a∪b)^{*}and (c∪d)^{*}.Note that for this type of problem, you could in principle start with regular expressions, NFA's, or DFA's for A and B and build either a regular expression, NFA, or DFA for S. In this problem it's easiest to work with DFA's, but in Problem 1.31, for example, there are fairly easy arguments for regular expressions and for NFA's, but not as far as I know for DFA's.

**Question 6, posted 14 February**Isn't there a typo, where the extra credit parts of 1.7 are e and g in one place, and e and h in another?Yeah, yeah, I'll give you credit for either but not both.

Last modified 14 February 2008