Answer: Finite automata
Question:
Which of the following are regular? Write regular expressions for
those that are. (You can use a period `.' to represent any character
in the alphabet (``(a_1|a_2|a_3|...|a_k)'', if the a_i are the
characters in the alphabat).)
- the set of all strings
- strings containing both ``smile'' and ``frown'' as substrings
- strings containing 211 as a subsequence (211 is a subsequence of
``25-100 is a 12-credit course'' because it
contains 211 in order)
- bit sequences representing numbers that are both prime and perfect.
(A number n is perfect if the sum of its factors (except
n) is n itself.)
Answer:
They all are.
- ``.*''
- ``(.*smile.*frown.*)|(.*frown.*smile.*)''
- ``.*2.*1.*1.*''
- the empty set (no strings); there isn't really a regular
expression for this. No prime numbers are perfect; their factors except
the number itself add up to only 1, and 1 isn't among the primes.
Answer /
Finite automata /
Review questions /
15-211 A, B