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 s and s
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 or a
Testing: test with in this order. Routputtxt
recognizer.cpp
#include
#include
using namespace std;
The recognizer function should return TRUE or FALSE
checking each character
to make sure it is or
bool recognizerstring 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 s and s
My generator.cpp must be used.
main: It should create each string over E 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 returns TRUE display
create returns TRUE display
create returns FALSE
create returns TRUE display
create returns TRUE display
create returns FALSE
create returns TRUE display and keep on going
create returns TRUE display and keep on going
The challenge here is to figure out how to create
all strings using and systematically, with no repeated
strings.
recognizer function: the same one from part Acopy and use
Testing: The user must somehow interactively terminate
the execution of the program after at least strings containing s and s have been displayed,
although your program should be able to keep on going until the queue overflows. Goutputtxt
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 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 controlC
after about strings have been displayed.
int main
whiletrue
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
