Project: PatternSearch

Monte Carlo & Las Vegas Pattern Search

Version 11/10/17

Educational Objectives: After completing this assignment, the student should be able to accomplish the following:

Operational Objectives: Design and implement the class template PatternSearch< Radix, Prime > that acts as a function object on input 2D arrays, returning the location of a first match or the size of the search space when no match is found.

Deliverables: Files:

ps.h           # definition & implementation of template< size_t Radix, size_t Prime > class PatternSearch
psdriver.cpp   # driver client 

makefile       # builds all project object code and executables
manual.txt     # operating instructions for software [team document]
report.txt     # overview of team and project [team document]
log.txt        # personal log for team member [individual document]

Submit command: submit.sh deliverables.rk

Code Requirements and Specifications

  1. PatternSearch should be a class template that generalizes the outline for RabinKarp given in Strings 3.

  2. Minimum required generalizations:

    1. Stream-based, so that an entire search space is not required in memory.
    2. Search for 2-dimensional patterns of characters in 2-dimensional text. Assume both pattern and text are rectangles of characters.

  3. I/O: An overloaded input operator, and a "verification display" are needed to support the application.

  4. Input Files: Specific line formatting of input files should not be required, so that if a file is reformatted (e.g., in "paragraphs") it will not affect the way the file is interpreted. The characters '\t' and '\n' (tab and newline) should be excluded from the pattern character set, and replaced with ' ' (blank) in patterns and search spaces.

  5. Be sure to conform to the specs:

    1. Monte Carlo Rule: The pattern is matched with high probability. The runtime is guaranteed O(n + k).
    2. Las Vegas Rule: The pattern match is guaranteed. The runtime is O(n + k) with high probability. Worst case runtime is Ω(n×k).

    Where n is incoming search space size and k is the pattern size.

  6. Probability: There should be a method long double Probability() const that returns the probability estimate of success under either rule.

  7. User Feedback: Most user interaction is handled by the driver program. There is one place where the PatternSearch class needs to send informative statements depending on specific results. See the class notes and/or the area51/frk.x executable for details. It is important to have your output conform to those.

Hints