140 likes | 268 Views
This article presents an efficient approach to identify Right Skew Pointers (RSP) from sequences of numbers using prefix sums and probabilistic analysis. It outlines the method of constructing right skew pointers for a given dataset, highlighting specific cases and computations for different segments of data. Through examples, we explore how prefix sums help rationalize the determination of these pointers. This methodology can be beneficial in various applications such as data analysis and algorithm optimization.
E N D
Right Skew Pointers 2 2 - - 1 3 1 7 0 1 1 3 1 7 0 1 - - 4 6 4 5 3 0 4 6 4 5 3 0 - - 2 2 - - 4 4 - - 8 8 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11 12 7 8 9 10 11 12 13 14 15 16 13 14 15 16 Right half Left half As a whole
Finding Right Skew Pointers S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 2 2 - - 1 3 1 7 0 1 1 3 1 7 0 1 - - 4 6 4 5 3 0 4 6 4 5 3 0 - - 2 2 - - 4 4 - - 8 8 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11 12 7 8 9 10 11 12 13 14 15 16 13 14 15 16 0.5 4.5 i=1 Prefix sum: 2, 1, 4, 5, 12, 12, 13, 9, 15, 19, 24, 27, 27, 25, 21, 13 μ(S1)=2.4, μ(S1S2)=13/7, μ(S1S2S3)=9/8, μ(S1…S4)=15/9, μ(S1…S5)=24/11, μ(S1…S6)=27/12, μ(S1…S7)=27/13, μ(S1…S8)=25/14, μ(S1…S9)=21/15, μ(S1…S10)=15/16, So the first DRSP(1,16) starting from i=1 is determined (at index 5).
Finding Right Skew Pointers S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 2 2 - - 1 3 1 7 0 1 1 3 1 7 0 1 - - 4 6 4 5 3 0 4 6 4 5 3 0 - - 2 2 - - 4 4 - - 8 8 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11 12 7 8 9 10 11 12 13 14 15 16 13 14 15 16 i=2 0.5 4.5 Prefix sum: -1, 2, 3, 10, 10, 11, 7, 13, 17, 22, 25, 25, 23, 19, 11 μ(S1)=2.5, μ(S1S2)=11/6, μ(S1S2S3)=7/7, μ(S1…S4)=13/8, μ(S1…S5)=22/10, μ(S1…S6)=25/11, μ(S1…S7)=27/13, μ(S1…S8)=23/13, μ(S1…S9)=19/14, μ(S1…S10)=11/15 So the first DRSP(2,16) starting from i=2 is determined (at index 5).
Finding Right Skew Pointers S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 2 2 - - 1 3 1 7 0 1 1 3 1 7 0 1 - - 4 6 4 5 3 0 4 6 4 5 3 0 - - 2 2 - - 4 4 - - 8 8 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11 12 7 8 9 10 11 12 13 14 15 16 13 14 15 16 i=3 0.5 4.5 Prefix sum: 3, 4, 11, 11, 12, 8, 14, 18, 23, 26, 26, 24, 20, 12 μ(S1)=11/3, μ(S1S2)=12/5, μ(S1…S3)=8/6, μ(S1…S4)=14/7, μ(S1…S5)=23/9, μ(S1…S6)=26/10, μ(S1…S7)=26/11, μ(S1…S8)=24/12, μ(S1…S9)=20/13, μ(S1…S10)=12/14 So the first DRSP(3,16) starting from i=3 is determined (at index 5).
Finding Right Skew Pointers S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 2 2 - - 1 3 1 7 0 1 1 3 1 7 0 1 - - 4 6 4 5 3 0 4 6 4 5 3 0 - - 2 2 - - 4 4 - - 8 8 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11 12 7 8 9 10 11 12 13 14 15 16 13 14 15 16 i=4 0.5 4.5 Prefix sum: 1, 8, 8, 9, 5, 11, 15, 20, 23, 23, 21, 17, 9 μ(S1)=8/2, μ(S1S2)=9/4, … obviously μ(S1) is the largest. So the first DRSP(4,16) starting from i=4 is determined (at index 5).
Finding Right Skew Pointers S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 2 2 - - 1 3 1 7 0 1 1 3 1 7 0 1 - - 4 6 4 5 3 0 4 6 4 5 3 0 - - 2 2 - - 4 4 - - 8 8 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11 12 7 8 9 10 11 12 13 14 15 16 13 14 15 16 i=5 0.5 4.5 Prefix sum: 7, 7, 8, 4, 10, 14, 19, 22, 22, 20, 16, 8 μ(S1)=8/2,…, … obviously μ(S1) is the largest. So the first DRSP(5,16) starting from i=5 is determined (at index 5).
Finding Right Skew Pointers S2 S3 S4 S5 S6 S7 S8 S9 S10 2 2 - - 1 3 1 7 0 1 1 3 1 7 0 1 - - 4 6 4 5 3 0 4 6 4 5 3 0 - - 2 2 - - 4 4 - - 8 8 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11 12 7 8 9 10 11 12 13 14 15 16 13 14 15 16 i=6 Prefix sum: 0, 1, -3, 3, 7, 12, 15, 15, 13, 9, 1 μ(S2)=1/2, μ(S2S3)=-3/3, μ(S2…S4)=3/4, μ(S2…S5)=12/6, μ(S2…S6)=15/7, μ(S2…S7)=15/8, μ(S2…S8)=13/9, μ(S2…S9)=9/10, μ(S2…S10)=1/11 So the first DRSP(6,16) starting from i=6 is determined (at index 12).
Finding Right Skew Pointers S2 S3 S4 S5 S6 S7 S8 S9 S10 2 2 - - 1 3 1 7 0 1 1 3 1 7 0 1 - - 4 6 4 5 3 0 4 6 4 5 3 0 - - 2 2 - - 4 4 - - 8 8 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11 12 7 8 9 10 11 12 13 14 15 16 13 14 15 16 i=7 Prefix sum: 1, -3, 3, 7, 12, 15, 15, 13, 9, 1 μ(S2)=1, μ(S2S3)=-3/2, μ(S2…S4)=3/3, μ(S2…S5)=12/5, μ(S2…S6)=15/6, μ(S2…S7)=15/7, μ(S2…S8)=13/8, μ(S2…S9)=9/9, μ(S2…S10)=1/10 So the first DRSP(7,16) starting from i=7 is determined (at index 12).
Finding Right Skew Pointers S2 S3 S4 S5 S6 S7 S8 S9 S10 2 2 - - 1 3 1 7 0 1 1 3 1 7 0 1 - - 4 6 4 5 3 0 4 6 4 5 3 0 - - 2 2 - - 4 4 - - 8 8 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11 12 7 8 9 10 11 12 13 14 15 16 13 14 15 16 i=8 Prefix sum: -4, 2, 6, 11, 14, 14, 12, 8, 0 μ(S3)=-4, μ(S3S4)=-2/2, μ(S3…S5)=11/4, μ(S3…S6)=14/5, μ(S3…S7)=14/6, μ(S3…S8)=12/7, μ(S3…S9)=8/8, μ(S3…S10)=0 So the first DRSP(8,16) starting from i=8 is determined (at index 12).
Finding Right Skew Pointers S2 S3 S4 S5 S6 S7 S8 S9 S10 2 2 - - 1 3 1 7 0 1 1 3 1 7 0 1 - - 4 6 4 5 3 0 4 6 4 5 3 0 - - 2 2 - - 4 4 - - 8 8 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11 12 7 8 9 10 11 12 13 14 15 16 13 14 15 16 i=8 Note that we have correctly find the right-skew pointers of the whole sequence. Prefix sum: -4, 2, 6, 11, 14, 14, 12, 8, 0 μ(S3)=-4, μ(S3S4)=-2/2, μ(S3…S5)=11/4, μ(S3…S6)=14/5, μ(S3…S7)=14/6, μ(S3…S8)=12/7, μ(S3…S9)=8/8, μ(S3…S10)=0 So the first DRSP(8,16) starting from i=8 is determined (at index 12).
Using Pointer-Jumping Table to Find the Maximum (Take i = 0 as an example) 2 2 - - 1 3 1 7 0 1 1 3 1 7 0 1 - - 4 6 4 5 3 0 4 6 4 5 3 0 - - 2 2 - - 4 4 - - 8 8 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11 12 7 8 9 10 11 12 13 14 15 16 13 14 15 16 Pointer -Jumping table i=1 TPJ(9,0)=9, TPJ(9,1)=11, TPJ(9,2)=13, TPJ(9,3)=16, TPJ(9,4) = 16 TPJ(10,0)=11, TPJ(10,1)=12, TPJ(10,2)=14, TPJ(10,3)=16, TPJ(10,4) = 16 TPJ(11,0)=11, TPJ(11,1)=12, TPJ(11,2)=14, TPJ(11,3)=16, TPJ(11,4) = 16 TPJ(12,0)=12, TPJ(12,1)=13, TPJ(12,2)=15, TPJ(12,3)=16, TPJ(12,4) = 16 TPJ(13,0)=13, TPJ(13,1)=14, TPJ(13,2)=16, TPJ(13,3)=16, TPJ(13,4) = 16 TPJ(14,0)=14, TPJ(14,1)=15, TPJ(14,2)=16, TPJ(14,3)=16, TPJ(10,4) = 16 TPJ(15,0)=15, TPJ(15,1)=16, TPJ(15,2)=16, TPJ(15,3)=16, TPJ(15,4) = 16 TPJ(16,0)=16, TPJ(16,1)=16, TPJ(16,2)=16, TPJ(16,3)=16, TPJ(16,4) = 16
μ(S1…S7)=27/13 Step1:μ(SLSR(TPJ(9,2)))=27/13 > μ(SLSR(TPJ(9,3)))=15/16 2 2 - - 1 3 1 7 0 1 1 3 1 7 0 1 - - 4 6 4 5 3 0 4 6 4 5 3 0 - - 2 2 - - 4 4 - - 8 8 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11 12 7 8 9 10 11 12 13 14 15 16 13 14 15 16 i=1 TPJ(9,0)=9, TPJ(9,1)=11, TPJ(9,2)=13, TPJ(9,3)=16 TPJ(10,0)=11, TPJ(10,1)=12, TPJ(10,2)=14, TPJ(10,3)=16 TPJ(11,0)=11, TPJ(11,1)=12, TPJ(11,2)=14, TPJ(11,3)=16 TPJ(12,0)=12, TPJ(12,1)=13, TPJ(12,2)=15, TPJ(12,3)=16 TPJ(13,0)=13, TPJ(13,1)=14, TPJ(13,2)=16, TPJ(13,3)=16 TPJ(14,0)=14, TPJ(14,1)=15, TPJ(14,2)=16, TPJ(14,3)=16 TPJ(15,0)=15, TPJ(15,1)=16, TPJ(15,2)=16, TPJ(15,3)=16 TPJ(16,0)=16, TPJ(16,1)=16, TPJ(16,2)=16, TPJ(16,3)=16 Pointer -Jumping table
Step1:μ(SLSR(TPJ(9,2)))=27/13 > μ(SLSR(P(TPJ(9,2)+1))=25/14 Step2:μ(SLSR(TPJ(9,1)))=24/11 < μ(SLSR(P(TPJ(9,1)+1)))=27/12 2 2 - - 1 3 1 7 0 1 1 3 1 7 0 1 - - 4 6 4 5 3 0 4 6 4 5 3 0 - - 2 2 - - 4 4 - - 8 8 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11 12 7 8 9 10 11 12 13 14 15 16 13 14 15 16 i=1 TPJ(9,0)=9, TPJ(9,1)=11, TPJ(9,2)=13, TPJ(9,3)=16 TPJ(10,0)=11, TPJ(10,1)=12, TPJ(10,2)=14, TPJ(10,3)=16 TPJ(11,0)=11, TPJ(11,1)=12, TPJ(11,2)=14, TPJ(11,3)=16 TPJ(12,0)=12, TPJ(12,1)=13, TPJ(12,2)=15, TPJ(12,3)=16 TPJ(13,0)=13, TPJ(13,1)=14, TPJ(13,2)=16, TPJ(13,3)=16 TPJ(14,0)=14, TPJ(14,1)=15, TPJ(14,2)=16, TPJ(14,3)=16 TPJ(15,0)=15, TPJ(15,1)=16, TPJ(15,2)=16, TPJ(15,3)=16 TPJ(16,0)=16, TPJ(16,1)=16, TPJ(16,2)=16, TPJ(16,3)=16 Pointer -Jumping table
Step1:μ(SLSR(TPJ(9,2)))=27/13 > μ(SLSR(P(TPJ(9,2)+1))=25/14 Step2:μ(SLSR(TPJ(9,1)))=24/11 < μ(SLSR(P(TPJ(9,1)+1)))=27/12 Step3:μ(SLSR(9,12) > μ(SLSR(P(12+1))) And μ(S1) > μ(SLSR(9,12)) So the maximal is at S1. 2 2 - - 1 3 1 7 0 1 1 3 1 7 0 1 - - 4 6 4 5 3 0 4 6 4 5 3 0 - - 2 2 - - 4 4 - - 8 8 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11 12 7 8 9 10 11 12 13 14 15 16 13 14 15 16 i=1 TPJ(9,0)=9, TPJ(9,1)=11, TPJ(9,2)=13, TPJ(9,3)=16 TPJ(10,0)=11, TPJ(10,1)=12, TPJ(10,2)=14, TPJ(10,3)=16 TPJ(11,0)=11, TPJ(11,1)=12, TPJ(11,2)=14, TPJ(11,3)=16 TPJ(12,0)=12, TPJ(12,1)=13, TPJ(12,2)=15, TPJ(12,3)=16 TPJ(13,0)=13, TPJ(13,1)=14, TPJ(13,2)=16, TPJ(13,3)=16 TPJ(14,0)=14, TPJ(14,1)=15, TPJ(14,2)=16, TPJ(14,3)=16 TPJ(15,0)=15, TPJ(15,1)=16, TPJ(15,2)=16, TPJ(15,3)=16 TPJ(16,0)=16, TPJ(16,1)=16, TPJ(16,2)=16, TPJ(16,3)=16 Pointer -Jumping table