Less Than Matching Orgad Keller.

Slides:



Advertisements
Similar presentations
TWO STEP EQUATIONS 1. SOLVE FOR X 2. DO THE ADDITION STEP FIRST
Advertisements

Copyright © Cengage Learning. All rights reserved.
Introduction to Algorithms
Bellwork If you roll a die, what is the probability that you roll a 2 or an odd number? P(2 or odd) 2. Is this an example of mutually exclusive, overlapping,
Advanced Piloting Cruise Plot.
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 5 Author: Julia Richards and R. Scott Hawley.
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Chapters 1 & 2 Theorem & Postulate Review Answers
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
©2001 by Charles E. Leiserson Introduction to AlgorithmsDay 9 L6.1 Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 6 Prof. Erik Demaine.
Summary of Convergence Tests for Series and Solved Problems
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
My Alphabet Book abcdefghijklm nopqrstuvwxyz.
0 - 0.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
MULTIPLYING MONOMIALS TIMES POLYNOMIALS (DISTRIBUTIVE PROPERTY)
ADDING INTEGERS 1. POS. + POS. = POS. 2. NEG. + NEG. = NEG. 3. POS. + NEG. OR NEG. + POS. SUBTRACT TAKE SIGN OF BIGGER ABSOLUTE VALUE.
SUBTRACTING INTEGERS 1. CHANGE THE SUBTRACTION SIGN TO ADDITION
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
ZMQS ZMQS
CS16: Introduction to Data Structures & Algorithms
Copyright 2012, 2008, 2004, 2000 Pearson Education, Inc.
BT Wholesale October Creating your own telephone network WHOLESALE CALLS LINE ASSOCIATED.
How to Tame Them How to Tame Them
Randomized Algorithms Randomized Algorithms CS648 1.
ABC Technology Project
© S Haughton more than 3?
© Charles van Marrewijk, An Introduction to Geographical Economics Brakman, Garretsen, and Van Marrewijk.
Quadratic Inequalities
How to convert a left linear grammar to a right linear grammar
Interesting Integers!.
Linking Verb? Action Verb or. Question 1 Define the term: action verb.
Squares and Square Root WALK. Solve each problem REVIEW:
Do you have the Maths Factor?. Maths Can you beat this term’s Maths Challenge?
Divide and Conquer (Merge Sort)
© 2012 National Heart Foundation of Australia. Slide 2.
Lets play bingo!!. Calculate: MEAN Calculate: MEDIAN
1 Chapter 4 The while loop and boolean operators Samuel Marateck ©2010.
Chapter 5 Test Review Sections 5-1 through 5-4.
GG Consulting, LLC I-SUITE. Source: TEA SHARS Frequently asked questions 2.
The Greenebox Factoring Method
What You Should Learn • Represent and classify real numbers.
1 First EMRAS II Technical Meeting IAEA Headquarters, Vienna, 19–23 January 2009.
Addition 1’s to 20.
25 seconds left…...
Test B, 100 Subtraction Facts
Introduction to Computability Theory
11 = This is the fact family. You say: 8+3=11 and 3+8=11
Solving Systems of Linear Equations By Elimination
Week 1.
We will resume in: 25 Minutes.
1 Unit 1 Kinematics Chapter 1 Day
PSSA Preparation.
Introduction to Computability Theory
How Cells Obtain Energy from Food
Introduction to Recursion and Recursive Algorithms
Week 10 Generalised functions, or distributions
Equivalence Relations
Incremental Linear Programming Linear programming involves finding a solution to the constraints, one that maximizes the given linear function of variables.
Parameterized Matching Amir, Farach, Muthukrishnan Orgad Keller Modified by Ariel Rosenfeld.
Complexity ©D.Moshkovitz 1 NPC More NP-Complete Problems.
1 Chapter Parsing Techniques. 2 Section 12.3 Parsing Techniques We know (via a theorem) that the context- free languages are exactly those languages.
Parametrized Matching Amir, Farach, Muthukrishnan Orgad Keller.
Orgad Keller Modified by Ariel Rosenfeld Less Than Matching.
Pattern Matching With Don’t Cares Clifford & Clifford’s Algorithm Orgad Keller.
Pattern Matching With Don’t Cares Clifford & Clifford’s Algorithm
Presentation transcript:

Less Than Matching Orgad Keller

Orgad Keller - Algorithms 2 - Recitation 12 Less Than Matching Input: A text , a pattern over alphabet with order relation . Output: All locations where Can we use the regular methods? Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Transitivity Less Than Matching is in fact transitive, but that is not enough for us: does not imply anything about the relation between and . Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Approach A good approach for solving Pattern Matching problems is sometimes solving: The problem for a binary alphabet . The problem for a bounded alphabet . The problem for an ubounded alphabet . In that order. Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Binary Alphabet The only case that prevents a match at location is the case where: This is equivalent to: So how can we solve this case? Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Binary Alphabet So if , there is no match at . We can calculate Then we’ll calculate using FFT. We’ll return all locations where Time: . Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Bounded Alphabet We need reductions to binary alphabet. For each we’ll define: We notice are binary. Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Bounded Alphabet Theorem: (less than) matches at location if and only if , (less than) matches at location . Proof: does not match at iff . that is true iff , meaning that does not (less than) match at location . Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Bounded Alphabet So for each , we’ll run the binary alphabet algorithm on . We’ll return only the locations that matched in all iterations. Time: . Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Unbounded Alphabet Running the bounded alphabet algorithm could result in a time algorithms (We’ll run it only for alphabet symbols which are actually in pattern). Can be worse than the naïve algorithm. We present an improvement on the next slides. Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Abrahamson-Kosaraju Method First, use the segment splitting trick. Therefore we can assume . For each location in text, we’ll produce a triplet: , where . For each location in pattern, we’ll produce a triplet: , where . We now have triplets all together. Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Abrahamson-Kosaraju Method We’ll hold all triplets together. Sort all triplets according to symbol. We’ll define a symbol that has more than triplets as a “frequent symbol”. There are frequent symbols. Put all frequent symbols’ triplets aside. Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Abrahamson-Kosaraju Method Split non-frequent symbols’ triplets to groups of size in the following manner: Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Abrahamson-Kosaraju Method The rule is that there can’t be two triplets of the same symbol in different groups. Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Abrahamson-Kosaraju Method For each such group, choose the symbol of the first triplet in group as the group’s representative. For instance, on previous example, group 1’s representative is and group 2’s representative is . There are representatives all together. Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Abrahamson-Kosaraju Method To sum up: frequent symbols. representatives of non-frequent symbols. We’ll swap each non-frequent symbol in pattern and text with its representative. Now our text and pattern are over sized alphabet. Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Abrahamson-Kosaraju Method We want to run our algorithm over the new text and pattern to count the mismatches between symbols of different groups. But we have a problem: Let’s say is a frequent symbol, but: Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Abrahamson-Kosaraju Method The representative of group 2 is , which is smaller than , but the group also contains which is greater than . Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Abrahamson-Kosaraju Method In that case we’ll split group 2 to two groups with their own representatives. Since we performed at most such splits, we still have representatives. Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Abrahamson-Kosaraju Method We can now run our algorithm over the new text and pattern in . But we still haven’t handled comparisons between two non-frequent symbols that are in the same group. Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Abrahamson-Kosaraju Method We’ll do so naively in each group: For each triplet in the group For each triplet of the form in the group, if , then add an error at location . Time: Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Running Time For one segment: Sorting the triplets and representatives: . Running the algorithm: . Correcting results (Adding in-group errors): . Overall for one segment: . Overall for all segments: . Orgad Keller - Algorithms 2 - Recitation 12

Orgad Keller - Algorithms 2 - Recitation 12 Running Time We can improve to . Left as an exercise. Orgad Keller - Algorithms 2 - Recitation 12