Algorithms and Data Structures

G52ADS Coursework for Autumn 2008

Informal Coursework 2

General Intro

The Assignment

The goal is to implement parenthesis matching using SimpleStack you have implemented in the first part of the informal coursework.
  1. Download the binary parenmatcher.jar and try running it using:

    java -jar parenmatcher.jar
  2. Download the sources in parenmatcher.zip, unpack them, and open in your favourite IDE.
  3. Start by looking at interfaces SimpleStringMatcher and StringMatcher either in the source code or in the corresponding in JavaDoc. You may want to check out CharOccurrence, if it could be of any use.
  4. Plug in your own implementation of SimpleStack from the previous exercise.
  5. Implement SimpleStringMatcher in SimpleStringMatcherImpl1 using SimpleStack.
  6. Implement StringMatcher in StringMatcherImpl1 using SimpleStack.
  7. Learn to use jUnit 4.5, if you have never used it before. (There could have been a lecture or two on JUnit by Dave Elliman in G51PRG.) Run jUnit tests SimpleStringMatcherImpl1Test and StringMatcherImpl1Test from SimpleTests suite. Make sure they do not fail.
  8. Check the run time of SimpleStringMatcherImpl1Test.testAllMatch_Performance. If it is too slow, rewrite the code to make it faster. (It matches parentheses in roughly 30 kB of text. Imagine you would open 2 MB of text. How long would it take? How does it relate to "the big O thing"?)

Submission

Feel free not to submit this. Please do work in pairs or groups. It's so much more fun!

See more of Jakub's homepage or the list of exercises, if you please.