« Weblogs are all the rage, eh? | Main | What is a She-Geek? »

Quick Quiz #1

Here's a quick quiz from the world of Finite State Automata
Welcome to the first of many geek.quizzes. This one comes from the webmaster's own course work, and isn't necessarily for the faint of heart. What's worse: I'm not going to teach any theory, so you'll have to wait until a future article or search separately on the web for an explanation of what's going on.

Just in case you've forgotten the notation, though, here are some reminders:

  • Each solid dot represents a state in the finite state automata.
  • Any unlisted transitions are assumed to go to a "dead state", or, if you prefer, stall the machine in a non-accepting state.
  • A circle around a state means that it is an accepting state for the machine.
  • And, for review, the regular expression that the FSA above represents is (00)*(11)*

 

 

 

 

 

 

What is the correct regular expression for the following FSA?

  1. (11 | 110)* 0
  2. 1(11)*(0|00)
  3. (1 | 0)*
  4. (0 | (11 (011 | 11)* (0 | 00)))
  5. (0 | (11 (011 | 11)* 0))
  6. (0 | 110 | 11 | 1100 | 11110)

spaces are for readability

A. (11 | 110)* 0 is Correct! This is actually the regular expression which was originally used to derive this FSA during a recent class I attended. But, there's another valid expression. Have you found it yet?

Back to the quiz

B.1(11)*(0|00) is incorrect. In fact, if you look closely, none of the strings it generates are correct. All valid strings from the FSA shown have an even number of 1's. This one requires an odd number, and doesn't allow 0's to occur all of the places they would from the provided FSA.

Back to the quiz

C.(1 | 0)* is incorrect. While it does match all of the strings in the language of the FSA, it matches many many more. In fact, this expression will take any string that can be constructed from the alphabet {1,0}.

Back to the quiz

D.(0 | (11 (011 | 11)* (0 | 00)) is correct. It is a much more complex regular expression than is necessary for the task, but it does correctly match the same strings as the FSA accepts. Have you found the simpler version yet?

Back to the quiz

E.(0 | (11 (011 | 11)* 0) is not correct. Nice try. This expression doesn't find 1100, which is one of the acceptable strings according to the FSA.

Back to the quiz

F.(0 | 110 | 11 | 1100 | 11110) is not correct. While it does include several of the shorter strings which this FSA accepts, this FSA recognizes strings of nearly any length, which are not represented by this expression.

Back to the quiz

Comments

You're weird.

Note that answer number 3, contrary to the comments, is not correct, in that it it not even a valid regular expression.

(0 | (11 (011 | 11)* (0 | 00))

...is missing a trailing ")", and thus is not correct for any state diagram.

Thanks, The RegExp Pedant

You twit. You go on and on about anal parenthesis matching, but you can't tell the difference between "it" and "is" in your post.

Thbbbt.

Oh yeah? Well, your mother likes Hot Grits.

Oh lighten up, it's not like you couldn't tell what he meant. Let's see you be perfect all the time. On the other hand, why does he want us to do his homework?

First Post!

Damn.

Twasn't a homework assignment. A better question would be whether you'd like to write something like this yourself. Needn't be out of coursework (though this was a spinoff of a cs507 lecture from spring 200), but that's certainly reasonable. Try not to steal a professor's homework/quiz questions, though, as I didn't here.

Thanks. I'm amazed at how many people I showed that to and how none of them had noticed that up until now.

Besides that, why do I get the feeling you were talking to yourself? I guess the Slashdot effect might be about more than just snowing a server with traffic as soon as its discovered.

Post a comment

Verification (needed to reduce spam):