Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Download: http://solutionzip.com/downloads/languageevaluator/
- Use stacks to evaluate if a given string is in a language L.
- The purpose of using a stack is to take advantage of its LIFO nature, therefore algorithms which merely use the stack for storage and determine inclusion of the string in the language by
- the use of counting the input string in any manner will NOT receive any credit.
- Let L1= { w: w contains equal numbers of A’s and B’s (in any order) and no other characters}
- L2 = { w: w is of the form AnBn, for some n >0 }
- L3 = { w: w is of the form AnB2n, for some n >0 }
- L4 = { w: w is of the form (AnBm)p, for some m,n,p >0 }
- w = AAABBB
- AB
- e
- ( the empty string)
- ABABABA
- ABAB
- BBAA
- BBBAA
- AAB
- AABBCCD
- ABCBA
- ABBBA
- ABBA
- ABAABBAAABBB
- AABACAB
- AA
- AABBBAABBB
- Test each string given as well as additional strings you make up yourself against each of the four
- languages. A non-trivial fifth language would be considered an enhancement. Be sure to discuss your data structures and their implementation and why they make sense. E.g. why is stack a reasonable choice to solve this problem? What implementation of a stack did you choose? Why?
- Note: You are expected to write the stack code yourself and not use the library stack class. Be sure to include the code for your stack as part of the source code you submit.
- Download: http://solutionzip.com/downloads/languageevaluator/
Add Comment
Please, Sign In to add comment