encoding nlv
DESCRIPTION
Data compressionTRANSCRIPT
![Page 1: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/1.jpg)
Nearest Larger Value Problem(s)
![Page 2: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/2.jpg)
Nearest Larger Value (NLV)
Given an array A[1…n] of size n
The Nearest Larger Value of A[i], NLV(i), returns the nearest position j to the query position i such that A[i] < A[j].
10 9 14 7 8 0 1 12 5 6
![Page 3: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/3.jpg)
Nearest Larger Value (NLV)
Given an array A[1…n] of size n
The Nearest Larger Value of A[i], NLV(i), returns the nearest position j to the query position i such that A[i] < A[j].
Ex)
NLV(5) = 3
10 9 14 7 8 0 1 12 5 6
![Page 4: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/4.jpg)
Nearest Larger Left/Right Value – NLLV/NLRV
Given an array A[1…n] of size n
The Nearest Larger Left Value of A[i], NLLV(i), returns the nearest position j such that j < i and A[i] < A[j].
10 9 14 7 8 0 1 12 5 6
![Page 5: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/5.jpg)
Nearest Larger Left/Right Value – NLLV/NLRV
Given an array A[1…n] of size n
The Nearest Larger Left Value of A[i], NLLV(i), returns the nearest position j such that j < i and A[i] < A[j].
Ex)
NLLV(5) = 3
NLRV(5) = 8
10 9 14 7 8 0 1 12 5 6
![Page 6: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/6.jpg)
Nearest Larger Value (NLV) on 2-dimensional array
Given an array A[1…n][1…n] of size n2
The Nearest Larger Value of A[i][j], NLV(i, j), returns the nearest position (k,l) (in terms of the L1-metric) such that A[k][l] > A[i][j].
11 6 7 6
10 1 8 1
4 5 3 4
2 9 3 10
![Page 7: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/7.jpg)
Nearest Larger Value (NLV) on 2-dimensional array
Given an array A[1…n][1…n] of size n2
The Nearest Larger Value of A[i][j], NLV(i, j), returns the nearest position (k,l) (in terms of the L1-metric) such that A[k][l] > A[i][j].
Ex) NLV(2, 3) = (2, 1)
11 6 7 6
10 1 8 1
4 5 3 4
2 9 3 10
![Page 8: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/8.jpg)
Problem
Construct an efficient (in terms of space and query-time) data structure which supports NLV/NLLV/NLRV-queries
on one and two-dimensional arrays.
![Page 9: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/9.jpg)
Encoding and Indexing models
Encoding model- The query algorithm cannot access the input data
Indexing model- The query algorithm can access the input data- Size of the data structure = size of index (excluding the input data)
![Page 10: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/10.jpg)
Results1-D
Model Space Time Problem
Fischer et al.
(TCS 2009)Indexing O(nlgc/c + pnlglgn/lgn
+ nlgn/cp) bitsO(cp)
(1≤c,p≤n) NLV, NLLV, NLRV
Fischer(TCS 2011) Encoding 2.54n + o(n) bits O(1)
Jayapaul et al. (IWOCA 2014)
Encoding 2n + o(n) bits O(1) NLV, distinct
Indexing O(n/c) bitsΘ(c)
(1≤c≤n) NLV
Indexing O(nlgc/c + nlgn/c2) bits O(c+lgn)(1≤c≤n) NLLV, NLRV
![Page 11: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/11.jpg)
Results
2-D
Model Space Time
Jo et al. (WALCOM 2015)
Encoding O(n2) bits O(1)
Indexing O(n2) bits O(lglglgn)
![Page 12: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/12.jpg)
Overall Structure1) Divide the array of size n2 into blocks of size (lgn)x(lgn). For each block, we define eight regions,consisting of sets of blocks (N, S, E, W, NE, NW, SE, SW)
Eight regions of the (2, 2)-block
5 6 9 7 15 6 14 12 4
14 11 7 13 12 10 5 1 13
10 5 1 8 7 1 7 4 9
15 5 4 13 4 4 9 0 6
20 7 9 6 13 1 1 2 7
2 9 6 3 7 10 18 14 4
14 11 17 5 18 2 15 3 4
5 17 14 2 6 8 4 6 0
6 14 6 16 12 3 4 12 19
NW
W
SW
NE
E
SE
S
N
![Page 13: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/13.jpg)
Overall Structure2) For each element, we store where its NLV we give a color to indicate one of 8 areas described above plus the block that contains the element. This takes O(n2) bits.
NLV(4,4) Region S, NLV(6,4) Region E,
NLV (6,5) Same block
5 6 9 7 15 6 14 12 4
14 11 7 13 12 10 5 1 13
10 5 1 8 7 1 7 4 9
15 5 4 13 4 4 9 0 6
20 7 9 1 13 1 1 2 7
2 9 1 3 2 10 18 14 4
14 11 17 5 18 2 15 3 4
5 17 14 2 6 8 4 6 0
6 14 6 16 12 3 4 12 19
![Page 14: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/14.jpg)
Overall Structure3) For each boundary element eB in block B, we store a pointer to the value which is closest to eBand larger than the maximum element of the block. This takes O(n2/lg2n*lg2n)=O(n2) bits.
5 6 9 7 15 6 14 12 4
14 11 7 13 12 10 5 1 13
10 5 1 8 7 1 7 4 9
15 5 4 13 4 4 9 0 6
20 7 9 1 13 1 1 2 7
2 9 6 3 2 10 18 14 4
14 11 17 5 18 2 15 3 4
5 17 14 2 6 8 4 6 0
6 14 6 16 12 3 4 12 19
![Page 15: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/15.jpg)
Overall Structure4) Now we divide each block into sub-blocks of size (√lgn)x(√lgn) and maintain a similar structure using O(n2) bits. Note that a maximal element in a sub-block which is not a maximal element in its block can have its answer outside the block, but its distance to NLV is bounded by O(lgn), and hence can be represented using O(lglg n) bits.
5 6 9 7 15 6 14 12 4
14 11 7 13 12 10 5 1 13
10 5 1 8 7 1 7 4 9
15 5 4 13 4 4 9 0 6
20 7 9 1 13 1 1 2 7
2 9 6 3 2 10 18 14 4
14 11 17 5 18 2 15 3 4
5 17 14 2 6 8 4 6 0
6 14 6 16 12 3 4 12 19
![Page 16: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/16.jpg)
Overall Structure5) To support NLV quires for non-maximal elements in a sub-block, we encode each sub-blocktogether with its 12 neighboring sub-blocks (with distance ≤2) by constructing a pre-computed table that is indexed by a linear-bit encoding (we describe this encoding later) of a sub-block and a position within it, and returns the NLV for that position. This takes O(2lgn) =O(n) bits.
5 6 9 7 15 6 14 12 4
14 11 7 13 12 10 5 1 13
10 5 1 8 7 1 7 4 9
15 5 4 13 4 4 9 0 6
20 7 9 1 13 1 1 2 7
2 9 6 3 2 10 18 14 4
14 11 17 5 18 2 15 3 4
5 17 14 2 6 8 4 6 0
6 14 6 16 12 3 4 12 19
![Page 17: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/17.jpg)
Linear-bit encoding for NLV on A[1…n][1…n]
We start with the 1-D case.- If elements in A[1…n] are distinct, we can encode NLV of elements using O(n) bits by writing down the pointer from every position to its NLV.- When the elements in A[1…n] are not distinct
we store the pointer from every position I in A to the nearest element, in the direction of NLV(i), whose value is larger or equal to A[i].We also store an additional bit that indicates whether the pointer from position i points to an element that is equal to A[i] or greater than A[i].
Theorem : This encoding takes O(n) bits.
7 1 8 4 5 8 3 8 1 2 10 9 8 8 10 11
![Page 18: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/18.jpg)
Linear-bit encoding for NLV on A[1…n][1…n]Now we extend the previous encoding to the 2-D case.
Let NLV(i, j) = (i*, j*) with i ≤ i* and j ≤j* (Other cases are similar)
Case (1) Let i’ > i be the smallest value such that i’ ≤ i* and A[i, j] = A[i’ , j]. If such an i’exists, we store a pointer from (i,j) to (i’, j) and set the extra bit to 0.
EX) Store the pointer (5,3) to (7,3) ( NLV(5,3)=(9,5) )
5 6 9 7 15 6 14 12 4
14 11 7 13 12 10 5 1 13
10 5 1 8 7 1 7 4 9
15 5 4 13 4 4 9 0 6
2 7 9 1 13 1 1 2 20
19 2 6 3 2 10 12 14 4
14 17 17 5 18 2 18 3 4
5 17 14 2 6 8 4 6 0
6 14 6 16 12 3 4 12 19
![Page 19: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/19.jpg)
Linear-bit encoding for NLV on A[1…n][1…n]Now we extend the previous encoding to the 2-D case.
Let NLV(i, j) = (i*, j*) with i ≤ i* and j ≤j*
Case (2) If not, let j’ > j be the smallest value such that j’ ≤ j* and A[i, j] =A[i, j’]. If such a j’ exists, we store a pointer from (i,j) to (i, j’) and set the extra bit to 0.
EX) Store the pointer (2, 2) to (2,3) ( NLV(2,2) = (1, 4) )
5 6 9 7 15 6 14 12 4
14 11 7 13 12 10 5 1 13
10 5 1 8 7 1 7 4 9
15 5 4 13 4 4 9 0 6
2 7 9 1 13 1 1 2 20
19 2 6 3 2 10 12 14 4
14 17 17 5 18 2 18 3 4
5 17 14 2 6 8 4 6 0
6 14 6 16 12 3 4 12 19
![Page 20: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/20.jpg)
Linear-bit encoding for NLV on A[1…n][1…n]Now we extend the previous encoding to the 2-D case. Let NLV(i, j) = (i*, j*) with i ≤ i* and j ≤j*
Case (3) Otherwise we store a pointer from (i,j) to (i*, j*) and set the extra bit to 1.Eg. Store pointers from (7, 2) to (9,4), and from (2,3) to (1,4)
(NLV(7,2) = (9,4), NLV(2,3) = (1,4) )
Theorem : This encoding takes O(n2) bits.
5 6 9 7 15 6 14 12 4
14 11 7 13 12 10 5 1 13
10 5 1 8 7 1 7 4 9
15 5 4 13 4 4 9 0 6
2 7 9 1 13 1 1 2 20
19 2 6 3 2 10 12 14 4
14 17 17 5 18 2 18 3 4
5 17 14 2 6 8 4 6 0
6 14 6 16 12 3 4 12 19
![Page 21: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/21.jpg)
Query algorithm1) If query is not a maximal element in its sub-block (we can check this using an O(n2)-bit structure), we use the pre-computed table to answer the query. This takes O(1) time.
5 6 9 7 15 6 14 12 4
14 11 7 13 12 10 5 1 13
10 5 1 8 7 1 7 4 9
15 5 4 13 4 4 9 0 6
20 7 9 1 13 1 1 2 7
2 9 6 3 2 10 18 14 4
14 11 17 5 18 2 15 3 4
5 17 14 2 6 8 4 6 0
6 14 6 16 12 3 4 12 19
![Page 22: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/22.jpg)
Query algorithm2) If query is a maximal element in a sub-block but not in a block, we can answer the query in O(1) time by finding the nearest boundary in the direction corresponding toq's assigned color.
(7,6)’s NLV is in the S-region of the sub-block. Go to the nearest boundary of the sub-block in the S direction and answer the query using explicitly-stored position.
5 6 9 7 15 6 14 12 4
14 11 7 13 12 10 5 1 13
10 5 1 8 7 1 7 4 9
15 5 4 13 4 4 9 0 6
20 7 9 1 13 1 1 2 7
2 9 6 3 2 10 18 14 4
14 11 17 5 18 2 15 3 4
5 17 14 2 6 8 4 6 0
6 14 6 16 12 3 4 12 19
![Page 23: Encoding NLV](https://reader038.vdocuments.mx/reader038/viewer/2022110323/55cf8fb9550346703b9f2c73/html5/thumbnails/23.jpg)
Query algorithm3) If query is a maximal element in a block, we can find its NLV in O(1) time by a similar procedure as in 2).
(5,9)’s NLV is in the SW-region of the block. Go to the nearest boundary of the block in the SWdirection and answer the query using explicitly-stored position.
5 6 9 7 15 6 14 12 4
14 11 7 13 12 10 5 1 13
10 5 1 8 7 1 7 4 9
15 5 4 13 4 4 9 0 6
20 7 9 1 13 1 1 2 7
2 9 6 3 2 10 18 14 4
14 11 17 5 18 2 15 3 4
5 17 14 2 6 8 4 6 0
6 14 6 16 12 3 4 12 19