Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

Students also viewed these Databases questions

Question

2. How much time should be allocated to the focus group?

Answered: 1 week ago

Question

1. Where will you recommend that she hold the focus group?

Answered: 1 week ago