I am new to Stacks and Queues and I am having a tough time answering the question below. If someone could guide me it would be of great assistance.
L={a^n b^n} where n ≥1, is a language of all words with the following properties:
The words are made up of strings of a’s followed by b’s.
The number of a’s is always equal to the number of b’s.
Examples of words that belong to L are
ab, where n=1;
aabb, where n=2;
aaabbb, where n=3;
aaaabbbb, where n=4.
One way to test if a word w belong to this language is to use a stack to check if the number of a’s balances the number of b’s. Use the provided header and write a function isInLanguageL that uses a stack to test if any word belongs to L.
bool isInLanguageL (string w);
Implement using a queue instead of a string as in the following header:
bool isInLanguageLQ (queueType<char> &w)
I am still reading up on the topic and trying to figure out what to do. I am very new to this so if I was pointed in the right direction, I am sure I would figure it out.
Always start by writing the basic outline of your program. You know most of the headers you will need, you know you will need a main function, you know you need to implement the functions required by th assignment. So, get a skeleton program written up.
Then, do what you know how until you get stuck, and then when you post your code and ask for help with what you're stuck on, we can help further.