Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Express each of these sets using a regular expression.

  1. The set of strings of one or more 0s followed by a 1
  2. The set of strings of two or more symbols followed by three or more 0s
  3. The set of strings with either no 1 preceding a 0 or no 0 preceding a 1
  4. The set of strings containing a string of 1s such that the number of 1s equals 2 modulo 3, followed by an even number of 0s

Short Answer

Expert verified
  1. Therefore, the regular expression for the given set is\({\bf{00*1}}\).
  2. Hence, the regular expression for the given set is \(\left( {0 \cup 1} \right)\left( {0 \cup 1} \right)\left( {0 \cup 1} \right){\bf{*00}}00{\bf{*}}\)
  3. So, the regular expression for the given set is\(0{\bf{*}}1{\bf{*}} \cup 1{\bf{*}}0{\bf{*}}\).
  4. Accordingly, the regular expression for the given set is\(11\left( {111} \right){\bf{*}}\left( {00} \right){\bf{*}}\).

Step by step solution

Achieve better grades quicker with Premium

  • Unlimited AI interaction
  • Study offline
  • Say goodbye to ads
  • Export flashcards

Over 22 million students worldwide already upgrade their learning with Vaia!

01

General form

Regular expressions (Definition):

The regular expressions over a set I are defined recursively by:

The symbol \(\emptyset \) is a regular expression.

The symbol \({\bf{\lambda }}\) is a regular expression.

The symbol xis a regular expression whenever \({\bf{x}} \in {\bf{I}}\).

The symbols \(\left( {{\bf{AB}}} \right){\bf{,}}\left( {{\bf{A}} \cup {\bf{B}}} \right){\bf{,}}\) and \({\bf{A*}}\) are regular expressions whenever Aand Bare regular expressions.

Rules of regular expression represent a set:

\(\emptyset \) represents the empty set, that is, the set with no strings.

\({\bf{\lambda }}\) represents the set \(\left\{ {\bf{\lambda }} \right\}\), which is the set containing the empty string.

xrepresents the set \(\left\{ {\bf{x}} \right\}\) containing the string with one symbol x.

(AB) represents the concatenation of the sets represented by Aand by B.

\(\left( {{\bf{A}} \cup {\bf{B}}} \right)\) represents the union of the sets represented by Aand by B.

\({\bf{A*}}\) represents the Kleene closure of the sets represented by A.

02

Step 2: Express the given sets using regular expressions

(a).

Given that,the set ofstrings of one or more 0s followed by a 1.

Express the given set as regular expression.

And the regular expression is\({\bf{00*1}}\).

So, the required expression is\({\bf{00*1}}\).

(b).

Given that,the set of strings of two or more symbols followed by three or more 0s.

Express the given set as a regular expression.

And the regular expression is\(\left( {0 \cup 1} \right)\left( {0 \cup 1} \right)\left( {0 \cup 1} \right){\bf{*00}}00{\bf{*}}\).

Hence, the required expression is\(\left( {0 \cup 1} \right)\left( {0 \cup 1} \right)\left( {0 \cup 1} \right){\bf{*00}}00{\bf{*}}\).

03

Express the given sets using regular expressions

(c).

Given that, the set of strings with either no 1 preceding a 0 or no 0 preceding a 1.

Express the given set as a regular expression.

And the regular expression is\(0{\bf{*}}1{\bf{*}} \cup 1{\bf{*}}0{\bf{*}}\).

Accordingly, the required expression is \(0{\bf{*}}1{\bf{*}} \cup 1{\bf{*}}0{\bf{*}}\).

(d).

Given that, the set of strings containing a string of 1s such that the number of 1s equals 2 modulo 3, followed by an even number of 0s.

Express the given set as regular expression.

And the regular expression is\(11\left( {111} \right){\bf{*}}\left( {00} \right){\bf{*}}\).

Therefore, the required expression is\(11\left( {111} \right){\bf{*}}\left( {00} \right){\bf{*}}\).

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

a)what is the language generated by a phrase-structure grammar G?

b)What is the language generated by the grammar Gwith vocabulary{S,0,1}, set of terminals T= {0,1}, starting symbol S, and productions Sโ†’000S, Sโ†’1?

c)Give a phrase-structure grammar that generates the set \({\bf{\{ 0}}{{\bf{1}}^{\bf{n}}}{\bf{|n = 0,1,2}}....{\bf{\} }}\).

Let \({\bf{G = }}\left( {{\bf{V, T, S, P}}} \right)\) be the context-free grammar with \({\bf{V = }}\left\{ {\left( {\bf{,}} \right){\bf{S,A,B}}} \right\}{\bf{, T = }}\left\{ {\left( {\bf{,}} \right)} \right\}\) starting symbol \({\bf{S}}\), and productions

Show that \({\bf{L}}\left( {\bf{G}} \right)\) is the set of all balanced strings of parentheses, defined in the preamble to Supplementary Exercise \(55\) in Chapter \(4\).

Describe the set of strings defined by each of these sets of productions in EBNF.

\(\begin{array}{c}\left( {\bf{a}} \right){\bf{string :: = L + D?L + }}\\{\bf{L :: = a }}\left| {{\bf{ b }}} \right|{\bf{ c }}\\{\bf{D :: = 0 | 1}}\\\left( {\bf{b}} \right){\bf{string :: = signD + |D + }}\\{\bf{sign :: = + | - }}\\{\bf{D :: = 0 | 1|2|3|4|5|6|7|8|9}}\\\left( {\bf{c}} \right){\bf{string :: = L*}}\left( {{\bf{D + }}} \right){\bf{?L* }}\\{\bf{L :: = x |y }}\\{\bf{D :: = 0 | 1}}\end{array}\)

Let V be an alphabet, and let A and B be subsets of \({\bf{V*}}\) Show that \({\bf{|AB}}\left| {{\rm{ }} \le {\rm{ }}} \right|{\bf{A||B|}}\).

Express each of these sets using a regular expression.

  1. The set consisting of the strings 0, 11, and 010
  2. The set of strings of three 0s followed by two or more 0s
  3. The set of strings of odd length
  4. The set of strings that contain exactly one 1
  5. The set of strings ending in 1 and not containing 000
See all solutions

Recommended explanations on Math Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free