1 / 31

An Improved Algorithm for the Rectangle Enclosure Problem

An Improved Algorithm for the Rectangle Enclosure Problem. Anatoli Uchitel From an article By D.T. Lee and F.P. Preparata (March 8, 1981). Introduction. This essay gives an algorithm for solving the Rectangle Enclosure problem in time and O(n) space

bunny
Download Presentation

An Improved Algorithm for the Rectangle Enclosure Problem

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. An Improved Algorithm for the Rectangle Enclosure Problem Anatoli Uchitel From an article By D.T. Lee and F.P. Preparata (March 8, 1981)

  2. Introduction • This essay gives an algorithm for solving the Rectangle Enclosure problem in time and O(n) space • n is the number of rectangles and q is the number of the required rectangle pairs

  3. Topics of Presentation • Introduction • Rectangle Enclosure and Dominance • A Two-Dimensional Subproblem • Time and Space Analysis

  4. Introduction • What is the Rectangle Enclosure problem ?Given a set of n rectangles in the plane, with sides parallel to the coordinate axes , find all q pairs of rectangles such that one rectangle of the pair encloses the other • The suggested solution achieves time using O(n) space

  5. Rectangle Enclosure and Dominance • We begin by transforming the rectangle enclosure problem into an equivalent one, which is easier to describe and understand • Let be a set of iso-oriented rectangles in the plane • For each i=1,…,n

  6. Transforming to Point Dominance problem • iff all the following hold:

  7. This is equivalent to:which expresses the relation “<“ of dominance between two four-dimensional points • Thus, after mapping each from R to its corresponding point in 4D we need to solve

  8. The Point Dominance Problem in 4D • Definition: p<q iff for i=1,2,3,4 where ui(p) is the i-th coordinate of p • Given a set , for each find

  9. Solving the dominance problem • Input : a set Required Output : all pairs of points (p,q)where p < q • Notation : the i-th coordinate of a point p will be donated by • Preliminary step : sort the elements of S by values in increasing orderIf two points have equal coordinates sort by etc. • Strategy : Divide & Conquer

  10. Algorithm Dominance • D1. ( Devide ) Partition S into S1 S2 where , • D2. ( Recur ) Solve the point-dominance problem on S1 and S2 separately • D3. ( Merge ) Find all pairs where ,

  11. Explaining the correctness of the algorithm • All dominance pairs within S1 and S2 will be found in D2. ( Recur ) • If there exists a dominance pair in which one point is from S1 ( say p ) and the other is from S2 ( say q ) , than it must be that p < q , since by construction

  12. Implementing D3 step - Merge • If and than by construction • Thus iff for l=2,3,4 • We have reduced the 4D problem to a 3D problem • let be the median of • Strategy : Divide & Conquer again

  13. Algorithm Merge • M1. ( devide ) Partition S1 into S11 S12 and S2 into S21 S22 whereS12 = S1-S11 S22 = S2-S21 • M2. ( Recur ) Solve the merge problem on the set pairs (S11,S21) and (S12,S22) • M3. (Combine) Find all pairs pi<pj such that and

  14. Why does that work? • By division : S = S11 S12 S21 S22 • Within each Sij the dominance pairs are found at step D2 since they are contained in S1 and S2 • About Dominant pairs where the points are from different subsets Sij we should notice that we should only examine cases where the dominant point is from a higher indexed set since the points are sorted by increasing order of u1 ( if u1 are the same a secondary sort by u2 is done etc. )

  15. The way all cases are processed • The solution includes the following cases: • (S21,S22) and (S11,S12) are processed in D2 since and • (S11,S21) and (S12,S22) are processed in M2( Recur in Merge ) • (S11,S22) is processed in M3 ( Combine in Merge ) • (S12,S21) need not be considered because for each and we have and

  16. Implementation of the Combine • The key operation of the entire task is therefore the implementation of step M3 ( the combine ) • Again we reduce the dimension of the problem, since the Combine step is a 2D merge problem ( in u3 and u4 )

  17. A Two-Dimensional Subproblem • Initial preprocessing : Construct a quadruply threaded list ( QTL ) with bidirectional links, for S. • for each p in S there is a node containing all the coordinate values and 8 pointers NEXTi,PREVi for i=1,2,3,4 that describe the ordering by the appropriate coordinates. • The construction of the QTL takes O(nlogn) time and O(n) space

  18. Explaining the algorithm for Combine • We traverse the points in S22 by the sort sorting order that u3 constrains ( NEXT32 ) • For each such point q in S22 we find all the points in S11 which is dominated by it in u3. This is done by traversing S11 by the sort sorting order that u3 constrains ( NEXT31 )

  19. For each such point p we insert u4(p) into the sorted list L. • When we reach p such that u3(p) > u3(q) we print all the points is S11 which are dominated by q, by traversing L from the beginning until reaching a point p’ for which u4(p’) > u4(q)

  20. J1 = BEG31; j2 = BEG32; // initialization while ( j2 != null){ if ((j1!=null) && (u3[j1] <= u3[j2])){ // if j2 dominates j1 by u3 L->insert_maintaining_order(u4[j1]); j1=NEXT3[j1]; } else { // j2 doesn’t dominate j1 l = BEGL; // print all the points in S11 which are dominated in both u3 and u4 by j2 while ((l!=null) and (u4[j2]>=u4[l])){ print(j2,l); l = NEXTL[l]; } j2 = NEXT3[j2]; } } Algorithm Combine

  21. Example

  22. The Crucial task of the procedure • How can we insert u4[j1] into L maintaining sorted order efficiently? • The naive approach would yield time • Using AVL Trees we can achieve O(|S1|log|S11|) • We can take advantage of the fact that the points are known in advance to achieve O(|S1|) total time

  23. Creating Schedule Of Insertion Into L in O(|S11|) • The Basic Idea :Let’s take a look at the point p in S11 which has the highest u3 value.We reach p after we processed all the other points from S11.It should be placed in L after PRED4[L] • Thus we can use PRED4 from the QTL in order to determine the schedule of insertion into L

  24. Algorithm insertion schedule l = last(u3 list) while ( PRED3[l] != BEG3 ) { NEXT4[PRED4[l]] = NEXT4[l]; PRED4[NEXT4[l]] = PRED4[l]; l = PRED3[l]; } • Final L is PREV4

  25. Example

  26. Time and Space Analysis • SpaceAll the processing is done in a place proportional by a constant to the QTL arrays, yielding O(n) space complexity • TimeNotations: • D(n) = The time complexity of the dominance algorithm • M3(r,s) = The time complexity of the merge algorithm • M2(r’,s’) = The time complexity of the combine algorithm

  27. Time Complexity - Dominance • Let |S|=n be an even number for simplicity • D(n) = 2D(n/2) + M3(n/2,n/2) + O(n) • D2. Recur step for S1 and S2 • D3. The Merge step on (S1,S2) • D1. The split of S to S1 and S2

  28. Time Complexity - Merge • Let r be an even number for simplicity • M3(r,s) = M3(r/2,m) + M3(r/2,s-m) + M2(r/2, max(m,s-m)) + O(r+s) • M2. Recur step for and • M3. Combine on • M1. Splitting S1 and S2 using the QTL

  29. Time Complexity - Combine • M2(r’,s’) = T(insertion schedule) + T(traversing S11 and S22 elements) + T(insertions to L) + T(printing of dominance pairs) = O(r’) + O(r’+s’) + O(r’) + O(q) = O(r’+s’+q) • Since the q dominance pairs are printed only once in the entire algorithm we can add O(q) to the final time complexity and say thatM2(r’,s’) = O(r’+s’) for the calculations

  30. Solving the equations M3(r,s) = M3(r/2,m) + M3(r/2,s-m) + O(r+s) Since the first parameter of M3 is always divided by 2 , we can make a bound M3(r,s) = O((r+s)log(r)) = O((r+s)log(r+s)) Thus, D(n) = 2D(n/2) + O(nlogn) ,which yields D(n) = Keeping in mind the debt for printing the pairs of dominance points we get that the final time complexity is

  31. Next Steps There are variations of this algorithm which improve the time complexity on account of the space complexity

More Related