 
Summary: Pattern Matching Algorithms 8977501 FINAL EXAM
MOED A
Instructor: Prof. Amihood Amir
Length of Exam: 2 hours
Time: 12:00, February 16th, 2010
BOOKS AND NOTEBOOKS ARE ALLOWED!!!
1. The PointSet Matching Problem is defined as follows.
INPUT: Text T = t0, ..., tn, and pattern P = p0, ..., pm,
pi, tj {0, 1}, i = 0, ..., m, j = 0, ..., n.
OUTPUT: All locations i in T where ti+j = pj or ti+j = 1 and pj = 0, j = 0, ..., m.
The text and pattern represent points on the line, where every 1 is a point. The idea
is to find the text locations where every pattern point aligns with a text point. (We do
not care if there are text points that do not align with pattern points.) text element.
Example: If T = 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1 and P = 1, 0, 0 then there is a match in
location 1 of the text, since the first location of the pattern matches the text, and there
are no more 1's in the pattern. Similarly, there is a match in text locations 2, 5, 7 and
8.
a) Write an algorithm that solves the PointSet Matching Problem (explain the algo
rithm's idea, the tools you used, and give a high level description).
b) What is the time complexity of your algorithm? Justify.
