Question
Write a recognizer in C++ for L = {x | x is a binary number} main: Given a string (from E) cined from the user,
Write a recognizer in C++ for L = {x | x is a binary number}
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.
recognizer function: Should return TRUE or FALSE checking each character
to make sure it is 0 or 1. (leading 0s are allowed).
Write a generator in C++ for L = {x | x is a binary number}.
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.
i.e.
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
[The challenge here is to figure out how to create
all strings using 0, 1 and 2 systematically, with no repeated
strings. Hint using a queue.]
Testing: The user must interactively terminate
the execution of the program after at least 20 binary strings
have been displayed although your program should be able to keep on going until the queue overflows.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started