Question text is in black, my answers in blue.
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.
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.)
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.
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.
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.
Yeah, yeah, I'll give you credit for either but not both.
Last modified 14 February 2008