1 / 34

Two Glass Balls and a Tower

Two Glass Balls and a Tower. Amihood Amir. Bar Ilan University And Georgia Tech. Costas Iliopoulos. Oren Kapah. Ely Porat. Artistic Consultant: Aviya Amir. Given: A glass ball. An n storied building.

zody
Download Presentation

Two Glass Balls and a Tower

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Two Glass Balls and a Tower Amihood Amir Bar Ilan University And Georgia Tech Costas Iliopoulos Oren Kapah Ely Porat Artistic Consultant:Aviya Amir

  2. Given: A glass ball. An n storied building. Find: The floor k such that the ball breaks when dropped from it, but does not break if dropped from floor k-1. KABLOOIE!!!

  3. STRATEGY 1: Only one ball given to experiment with. n n-1 4 3 2 1 O(n) experiments necessary. Sequential search.

  4. STRATEGY 2: As many balls as necessary are given to experiment with. O(log n) experiments necessary. Binary search.

  5. STRATEGY 3: Only two balls given to experiment with. O( ) experiments necessary. Bounded divide-and-conquer Experiments 1st ball Experiments 2nd ball

  6. Meaning of two Balls “Bounded” Divide-and-Conquer. In reality: Different paradigms. 1. Works on large groups. 2. Works within a group.

  7. In Pattern Matching • Works on large groups: • Convolutions: b0 b1 b2 b0 b1 b2 b0 b1 b2 O(n log m) using FFT

  8. Problem:O(n log m) only in algebraically closed fields, e.g. C. Solution: Reduce problem to (Boolean/integer/real) multiplication. This reduction costs! Example: Hamming distance. A B A B C A B B B A Counting mismatches is equivalent to Counting matches

  9. Example: 1 0 1 1 0 1 1 0 1 Count all “hits” of 1 in pattern and 1 in text.

  10. For Define: 1 if a=b 0 o/w Example:

  11. For Do: + + Result: The number of times a in pattern matches a in text + the number of times b in pattern matches b in text + the number of times c in pattern matches c in text.

  12. So for alphabet with a symbols (a fixed) the time is: O(n a log m) = O(n log m) Problem: Infinite alphabets.

  13. Without loss of generality: |S | = m + 1 Since every element of T not in P is replaced by some symbol x not in P. Example: ABCDEFGH same number of errors as ABXXXXGH ABBBBBGH ABBBB BGH

  14. Divide and Conquer Idea (Wrong) SplitS to S1 US2of size m/2 each. ConstructT1, P1 and T2, P2. Where for S = { T, P } and e = { 1, 2 }: if o/w

  15. The Algorithm • Findnum1= number of matches ofP1inT1 • Findnum2 = number of matches ofP2in T2 • 3. matches num1 + num2 Time:O(n) every iteration for changing alphabet.

  16. Time:T(m)=2T(m/2) + n. Closed Form: T(m) = 2i T(m/2i) + (2i-1 + 2i-2 + … + 2 + 1) n = (2 log m + … + 2 + 1) n = O(m2 n) THIS IS BAD !!!

  17. Needed: Faster way to compute matches of x to itself. Such a method exists if x appears in the pattern a very small number of times. Assume: x appears in pattern c times. For every occurrence of x in text, update just the appropriate counters of the c occurrences of x in the pattern. Text: Pattern: Time: O(nc).

  18. Problem: In general it could be that x occurs in the pattern O(m) times, then total time becomes O(nm).BAD again. Tradeoff: If x appears in the pattern more than c times, count matches by FFT, in time O(n log m), per x. For all x’s that appear in the pattern less than c times, count matches (simultaneously) in time O(nc).

  19. How many elements appear at least c times? For these elements , time:O((m/c) n log m). For all other elements,time: O(nc). The optimal case is when they equal, i.e. Total Time: (A-87,K-87)

  20. In our Tower Metaphor: <c Every element within the group is taken care of individually. However, all groups are “scanned” together. <c <c A Separate convolution for each group of floors (repetitions of a number x). >c >c >c >c

  21. Weighted Sequences Alignment of “similar” sequences – one of the challenges of string matching. Assume: from a set of sequences over alphabet S= , a set of “probabilities” is constructed as follows: Text: i a1 a2 ak Where is the probability that symbol aj occurs in text location i. .

  22. This text of probabilities is called a weighted sequence. Our problem: Given: Weighted sequence T, pattern P=s1,…,sm, and probability a. Find: All text locations i such that P occurs there with probability > a, i.e. . Example: Pattern ACDB occurs at location 2 of the text with probability

  23. Iliopoulos et. al. , in a number of recent papers answer the following questions about weighted sequences: • Do exact matching. • Construct weighted suffix tree for indexing. • Exact Matching: • Convert probabilities to logarithms. Now we use sums rather than products. • Consider every text row separately.Let Tabe the text row of a, for some Then the log probability of the pattern at every location is given by the formula:

  24. Example: P = ABABCAB 1010 0 10 x TA Gives the sum of thelog probabilities of A. 0101 001 x TBGives the sum of the log probabilities of B. 000 0100 x TC Gives the sum of the log probabilities of C. Add them all up and get the result. Time:O(n log m).

  25. Weighted Hamming Distance (A, Iliopoulos, Kapah – 06) Compute the smallest number of mismatches for every location. Mismatches are not symmetric. If errors are assumed to be in the text: How many text elements need to be changed (so that they will have probability 1 matching the corresponding pattern symbol) to produce a match at each location? Example: Text ,pattern ACDB, a=1/3. There exists a match at location 2 with 1 mismatch. 0001

  26. If errors assumed to be in the pattern: How many pattern symbols need to be replaced in order to have a match at a given location? Example: For Text ,pattern ACDB, and a=1/3 no match exists in location 2 even with 4 mismatches since every element already has highest probability. So changing the pattern letter D to A,B, or C will leave the same probability.

  27. We solve both types of mismatch weighted sequences problems, (as well as a few flavors of edit distance). Here we show the simpler of the two mismatch definitions – changes to text. We solve a more general problem: Input: Text where N. Pattern . Natural number e. Find: For every text location i, the smallest number of text locations that, when changed to 0, bring the convolution result to be no greater than e. (We change the negatives to positives and dropped the requirement that the numbers be log probabilities of weighted sequences.)

  28. We use the Tower Metaphor. Assumption:n<2m+1. Observation: For every text location we need to sort all O(m) text elements, and find out what is the precise point where the sum of all elements becomes less than e.

  29. Text elements sorted (biggest at bottom, smallest on top) First find the block where the sum is still . Then Find where that change occurs within the block. Need to known: For each text location, how many text elements from each block.

  30. How many text elements in each block? One convolution per block. Let Tj be such that Do convolution: for every block jand save in each text location. Time:

  31. Let Tj be For every block j do: We now know for each text location what is the sum of block values less than e and how many such values exist. All we need to do is find exact number within the seam block. For every text location: For every element in seam block, from top to bottom: If element matches 1 in pattern, multiply. Until number exceeds e.

  32. Example: 1 1 11 1 8 9 9 7 6 8 9 Implementation: Keep index for every element in every block, subtract from it the index of text location i and check if it hits a 1. Total Time for correction:

  33. As always, taking block sizes rather than Will make the Total Time:

More Related