Question: A ) Write a recognizer in C + + for L = { x | x contains any combination of 0 s and 1 s

A) Write a recognizer in C++ for L ={x | x contains any combination of 0s and 1s }
My recognizer.cpp must be used.
main: Given a string (from ) cined from the user, pass it to
the recognizer function.
Cout YES IN L or NO NOT IN L depending on what was returned.
recognizer function: Should return TRUE or FALSE checking each character
to make sure it is an 0 or a 1.
Testing: test with 0,1,00110,2,02,31 in this order. Routput.txt
recognizer.cpp
#include
#include
using namespace std;
// The recognizer function should return TRUE or FALSE
// checking each character
// to make sure it is 0 or 1.
bool recognizer(string s)
{**
}// end of recognizer
//main: Given a string (from E) cined from the user, pass it to
// the recognizer function.
// Cout "YES IN L" or "NO NOT IN L" depending on what was returned.
int main()
{**
// feel free to put it in a loop
}// end of main
B) Write a generator in C++ for L ={x | x contains any combination of 0s and 1s}.
My generator.cpp must be used.
main: It should create each string over E ={0,1,2} systematically
(short to long) and pass each string to the recognizer function
created in Part a) above.
Only those strings for which the recognizer returned TRUE
should be displayed.
for example,
create 0--> returns TRUE ---> display 0
create 1--> returns TRUE ---> display 1
create 2--> returns FALSE
create 00--> returns TRUE ---> display 00
create 01--> returns TRUE ---> display 01
create 02--> returns FALSE
create 10--> returns TRUE ---> display 10 and keep on going
create 11--> returns TRUE ---> display 11 and keep on going
[The challenge here is to figure out how to create
all strings using 0,1 and 2 systematically, with no repeated
strings. ]
recognizer function: the same one from part A)(copy and use)
Testing: The user must somehow interactively terminate
the execution of the program after at least 20 strings containing 0s and 1s have been displayed,
although your program should be able to keep on going until the queue overflows. Goutput.txt
generator.cpp
#include
#include
using namespace std;
**// include queue.h or equivalent such as
//----------------------------------------------
// Copy the recognizer function here from the other file.
**
// main: It should create each string over E ={0,1,2} systematically
//(short to long) and pass each string to the recognizer function
// created in Part a). Hint: use a queue to generate strings
// Only those strings for which the recognizer returned TRUE
// should be displayed.
// Keeps on going until the queue overflows but the user can
// terminate the program with control-C
// after about 20 strings have been displayed.
int main()
{**
while(true)
{
**// generate a string
**// if the recognizer says true, display it
}// end of while
}// end of main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!