Question
c++ I learned that we cannot recognize the languages like a n b n using FSM (basically, we need to output 1 whenever # of
c++
I learned that we cannot recognize the languages like anbn using FSM (basically, we need to output 1 whenever # of a's followed by same # of b's. So, ab, aabb, aaabbb are in that language, but aa, aab, ba, bbaa, aaabb... are not in that language). However, if I add a few variables, then we can recognize the language!
How do I write code to recognize the following languages(in c++):
L1 = {anbncndn for any n > 0, a, b, c & d are the possible input symbols} For example, abcd, aabbccdd are in the language, whereas abd, ad, aabcd, dbca, dcba ... are not in the language. For this first language, L1, You are allowed to have 2 variables (Interestingly, anbncmdm for any n, m > 0 requires only one variable - how?)
L2 = {any string made up of a's and b's s.t. # of a's is same as # of b's, a, & b the possible input symbols}. For this language L2, You are allowed to have only one additional variable.
Include your code and a few screenshots showing the sample runs for specified strings above.
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