Longest Increasing Subsequences in Windows Based on Canonical
Longest Increasing Subsequences in Windows Based on Canonical Antichain Partition Erdong Chen (Joint work with Linji Yang & Hao Yuan) Shanghai Jiao Tong Univ.
Outline l l l Problem Definition Canonical Antichain Partition Sweep Algorithm Complexity Analysis Conclusion
Longest Increasing Subsequence (LIS) Input sequence: 6 9 8 2 3 5 1 4 7 All Longest Increasing Subsequences: 2 3 5 2 3 7 4 7
LIS in a Window 6 9 8 2 3 5 1 4 7 6 9 8 6 9 Sequence a Window The length of LIS within the window is 2
Longest Increasing Sequence in A Set of Variable-size Windows (LISSET) 6 9 8 2 3 5 1 4 7 6 9 Length of LIS = 2 + 2 3 5 Length of LIS = 3 3 5 + Length of LIS = 2 2 3 5 + Length of LIS = 4 7 = OUTPUT = 11
Longest Increasing Sequence in A Set of Variable-size Windows (LISSET) 6 9 8 2 3 5 1 4 7 6 9 Length of LIS = 2 + 2 3 5 Length of LIS = 3 3 5 + Length of LIS = 2 2 3 5 + Length of LIS = 4 7 = OUTPUT = 11
Related Works l l l Knuth proposed an O(n log n) algorithm for LIS problem Fredman proved an Ω(n log n) lower bound under the decision tree model An O(n log n) algorithm is possible by using van Emde Boas tree on a permutation.
Related Works (Cont. ) l l Longest Increasing Subsequences in Sliding Windows (LISW problem) (by Michael H. Albert et al), Time Complexity O(OUTPUT + n log n) We called it Longest Increasing Subsequences in Fixed-size windows
LISW Problem n=6 6 9 8 2 3 5 w=3 6 9 88 22 333 5 6 9 9 2 3 5 n+w-1 = 8 windows 3 5 5 OUTPUT = 14 = Length of LIS = 1 + Length of LIS = 2 + Length of LIS = 3 + Length of LIS = 2 + Length of LIS = 1
Our Contribution A algorithm for the generalized problem LISSET l To solve the sub case LISW problem, our algorithm runs in O(OUTPUT) time. The best result among previous attempts on LISW is O(OUTPUT + n log n) l
Canonical Antichain Partition p 2(2, 9) p 3(3, 8) p 9(9, 7) p 1(1, 6) p 6(6, 5) p 8(8, 4) p 5(5, 3) p 4(4, 2) p 7(7, 1) The sequence: 6, 9, 8, 2, 3, 5, 1, 4, 7
Dominance Order p 2(2, 9) p 3(3, 8) a<b iff xa<xb & ya<yb Points in this region Points in this dominates p 1 region dominates p 4 p 9(9, 7) p 1(1, 6) p 6(6, 5) p 8(8, 4) p 5(5, 3) p 4(4, 2) p 7(7, 1)
Height of points by Dominance Order p 2 p 3 p 9 p 1 p 6 Height = 1 p 8 p 5 p 4 p 7
Height of points by Dominance Order p 2 p 3 Height = 2 p 1 p 6 Height = 1 p 8 p 5 p 4 p 7
Height of points by Dominance Order p 2 Height = 4 p 3 Height = 2 Height = 3 p 1 p 6 Height = 1 p 8 p 5 p 4 p 7
Antichain and Chain L(1) L(2) L(3) L(4) p 2=HEAD(2) p 3 p 9=HEAD(4) =TAIL(4) p 1=HEAD(1) p 6=HEAD(3) p 8=TAIL(3) p 4 Antichain: xi<xi+1 & yi>=yi+1 p 5=TAIL(2 ) p 7=TAIL(1)
Antichain and Chain L(1) L(2) L(3) L(4) p 2 Chain: xi<xi+1 & yi<yi+1 p 3 Max Element p 9 p 1 p 6 p 8 p 5 Min Element The longest chain <p 4, p 5, p 6, p 9> corresponds the LIS p 4 p 7 The sequence: 6, 9, 8, 2, 3, 5, 1, <2, 3, 5, 7> 4, 7
Sweep Algorithm l Sweep from left to right 6 9 8 2 l Operations – – – l DELETE operation (Delete at left) e. g. : delete 6 INSERT operation (Insert at right) e. g. : insert 2 QUERY operation Algorithm Flow
DELETE operation L(1) L(2) L(3) D(1) = {p 1} D(2) = {p 2} p 4 p 5 D(3) = {p 4, p 5} p 2 p 6 p 1=pdel p 7 p 3
DELETE operation (Cont. ) D(2) D(3) p 4 L(3)/D(3) p 5 p 2 L(2)/D(2) p 6 L(1)/D(1) p 1=pdel p 7 p 3
After the Delete operation L’(3) L’(2) L’(1) p 4 p 5 p 2 p 6 p 1=pdel p 7 p 3
Analysis of Delete operation l Theorem 2. The cost of one DELETE operation equals the total number of points whose height decreases, i. e. , O(|D|).
INSERT & QUERY operations l l Theorem 3. The cost of INSERT operation equals the length of the LIS with the p. INS as the maximum element. Theorem 4. The cost of outputting a longest chain equals to the length of the output subsequence.
Algorithm Flow l l l Step 1: Sort the windows Wi by their left endpoints (if two windows share the same left endpoint, the longer window comes first) O(n+m) Step 2: initialize current window to ∅ Step 3: slide the window from Wj to Wj+1 (j=1, 2, …m-1)
Details of Step 3 l l Move from Wj to Wj+1, Wj=(a 1, b 1), Wj+1=(a 2, b 2) Disjoint Overlap Contain – – l Same left endpoint Different left endpoints QUERY(r 2) to output a LIS within Wj+1
Amotized Complexity Analysis l l Given a sequence π = π1π2. . . πn depthi is defined to be the largest height that πi achieved in the m windows. In other words, among all increasing subsequences in m windows, depthi is the length of the longest one with πi as the maximal element.
Complexity of each operation by Amortize Analysis l QUERY operation: O(OUTPUT) l INSERT operation: l DELETE operations: (A point pi can decrease at most depthi times)
Complexity Analysis of LISSET l Theorem 5 (LISSET Problem). The algorithm described above computes the m longest increasing subsequences, one for each window, in total time:
Complexity Analysis of LISW l depthi equals the length of the output in window πi-w+1, πi-w+2, …, πi l So, l And, l Thus,
Complexity Analysis of LISW l Theorem 6 (LISW Problem). Our algorithm finds the longest increasing subsequence in a sliding window over a sequence of n elements in O(OUTPUT) time.
Future Works…
Questions?
- Slides: 32