Advertisement
akosiraff

Stack Implementation

Jun 15th, 2014
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1.  
  2. Download: http://solutionzip.com/downloads/stack-implementation/
  3. Use stacks to evaluate if a given string is in a language L. Your code will not be recursive. In your analysis, suggest a recursive algorithm and compare with your stack based solution. 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.
  4. Let L1= { w: w contains equal numbers of A’s and B’s (in any order) and no other characters}
  5. L2 = { w: w is of the form AnBn, for some n > 0 }
  6. L3 = { w: w is of the form AnB2n, for some n > 0 }
  7. L4 = { w: w is of the form (AnBm)p, for some m,n,p > 0 }
  8. L5 = { a non-trivial language of your choice}
  9. Examples of languages which are only trivially different from L1 and L2:
  10. L5 = { w: w contains equal numbers of C’s and D’s (in any order) and no other characters},
  11. L5 = { w: w is of the form CnDn for some n > 0 },
  12. L5 = { w: w is of the form BnAn for some n > 0 }.
  13. w = AAABBB
  14. AB
  15. e ( the empty string)
  16. ABABABA
  17. ABAB
  18. BBAA
  19. BBBAA
  20. AAB
  21. AABBCCD
  22. ABCBA
  23. ABBBA
  24. ABBA
  25. ABAABBAAABBB
  26. AABACABAA
  27. AABBBAABBB
  28. Test each string given as well as additional strings you make up yourself against each of the five languages. A sixth language would be considered an enhancement.
  29. 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? As stated above, consider a recursive solution and compare it to your iterative solution. Is one better than the other? If so, why?
  30. 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.
  31. Download: http://solutionzip.com/downloads/stack-implementation/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement