Discrete Range Maximum

Slides:



Advertisements
Similar presentations
Time-Space Trade-Offs for 2D Range Minimum Queries Gerth Stølting BrodalPooya Davoodi Aarhus University S. Srinivasa Rao Seoul National University 18 th.
Advertisements

Succinct Data Structures for Permutations, Functions and Suffix Arrays
Gerth Stølting Brodal University of Aarhus Monday June 9, 2008, IT University of Copenhagen, Denmark International PhD School in Algorithms for Advanced.
An Improved Succinct Dynamic k-Ary Tree Representation (work in progress) Diego Arroyuelo Department of Computer Science, Universidad de Chile.
Msb(x) in O(1) steps using 5 multiplications Word size n = g∙g, g a power of 2 [M.L. Fredman, D.E. Willard, Surpassing the information-theoretic bound.
Fusion Trees Advanced Data Structures Aris Tentes.
Suffix Sorting & Related Algoritmics Martin Farach-Colton Rutgers University USA.
Advanced Topics in Algorithms and Data Structures 1 Rooting a tree For doing any tree computation, we need to know the parent p ( v ) for each node v.
Data Structures: Range Queries - Space Efficiency Pooya Davoodi Aarhus University PhD Defense July 4, 2011.
Time-Space Trade-Offs for 2D Range Minimum Queries
1 Nearest Commen Ancestors (NCA) Discrete Range Maximum Cartesian Tree [Vuillemin 1980] i j max(i, j) i.
Lowest common ancestors. Write an Euler tour of the tree LCA(1,5) = 3 Shallowest node.
I/O-Efficient Structures for Orthogonal Range Max and Stabbing Max Queries Second Year Project Presentation Ke Yi Advisor: Lars Arge Committee: Pankaj.
Improvements on the Range-Minimum-Query- Problem
Lecture 11 : More Geometric Data Structures Computational Geometry Prof. Dr. Th. Ottmann 1 Geometric Data Structures 1.Rectangle Intersection 2.Segment.
Heaps and heapsort COMP171 Fall 2005 Part 2. Sorting III / Slide 2 Heap: array implementation Is it a good idea to store arbitrary.
Algorithm Engineering, September 2013Data Structures, February-March 2010Data Structures, February-March 2006 Cache-Oblivious and Cache-Aware Algorithms,
The Encoding Complexity of Two Dimensional Range Minimum Data Structures MADALGO, October 2, 2013 (Work presented at ESA 2013) 1234  n
The Encoding Complexity of Two Dimensional Range Minimum Data Structures European Symposium on Algorithms, Inria, Sophia Antipolis, France, September 3,
Compressed suffix arrays and suffix trees with applications to text indexing and string matching.
Introduction n – length of text, m – length of search pattern string Generally suffix tree construction takes O(n) time, O(n) space and searching takes.
14/13/15 CMPS 3130/6130 Computational Geometry Spring 2015 Windowing Carola Wenk CMPS 3130/6130 Computational Geometry.
Sorting with Heaps Observation: Removal of the largest item from a heap can be performed in O(log n) time Another observation: Nodes are removed in order.
Data Structure & Algorithm II.  Delete-min  Building a heap in O(n) time  Heap Sort.
DATA STRUCTURES Queues ‘n Stacks Tries, Suffix Trees Heaps Sieve of Eratosthenes.
The LCA Problem Revisited
Main Index Contents 11 Main Index Contents Complete Binary Tree Example Complete Binary Tree Example Maximum and Minimum Heaps Example Maximum and Minimum.
1 Nearest Common Ancestors (NCA) Discrete Range Maximum Cartesian Tree [Vuillemin 1980] i j max(i, j) i.
Fall 2008Simple Parallel Algorithms1. Fall 2008Simple Parallel Algorithms2 Scalar Product of Two Vectors Let a = (a 1, a 2, …, a n ); b = (b 1, b 2, …,
Optimal Planar Orthogonal Skyline Counting Queries Gerth Stølting Brodal and Kasper Green Larsen Aarhus University 14th Scandinavian Workshop on Algorithm.
ENCODING NEAREST LARGER VALUES Pat Nicholson* and Rajeev Raman** * MPII ** University of Leicester.
Discrete Methods in Mathematical Informatics Kunihiko Sadakane The University of Tokyo
Interval Trees Marco Gallotta. Problem ● Given a collection of items i, each with value V i ● Want to answer many queries of the form: How many items.
Succinct Data Structures
Chapter 11 Sorting Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++, Goodrich, Tamassia and Mount.
School of Computing Clemson University Fall, 2012
"Teachers open the door, but you must enter by yourself. "
Succinct Data Structures
Tries 07/28/16 11:04 Text Compression
Data Structures: Disjoint Sets, Segment Trees, Fenwick Trees
Succinct Data Structures
Succinct Data Structures
Succinct Data Structures
List Order Maintenance
Discrete Methods in Mathematical Informatics
Priority Queues An abstract data type (ADT) Similar to a queue
Two equivalent problems
Persistent Data Structures (Version Control)
Succinct Data Structures
Ariel Rosenfeld Bar-Ilan Uni.
Heaps © 2010 Goodrich, Tamassia Heaps Heaps
Data Structures: Segment Trees, Fenwick Trees
Minimum Spanning Tree Verification
Algorithm design and Analysis
Priority Queue & Heap CSCI 3110 Nan Chen.
Reporting (1-D) Given a set of points S on the line, preprocess them to build structure that allows efficient queries of the from: Given an interval I=[x1,x2]
Tree Representation Heap.
Discrete Methods in Mathematical Informatics
"Teachers open the door, but you must enter by yourself. "
Strict Fibonacci Heaps
Searching CLRS, Sections 9.1 – 9.3.
Minimizing the Aggregate Movements for Interval Coverage
Approximating Points by A Piecewise Linear Function: I
Binary and Binomial Heaps
Aggregate-Max Nearest Neighbor Searching in the Plane
HEAPS.
Priority Queues Supports the following operations. Insert element x.
CSE 589 Applied Algorithms Spring 1999
We have the following incomplete B&B tree:
Presentation transcript:

Discrete Range Maximum Nearest Common Ancestors (NCA) Org. [D. Harel, R.E. Tarjan, Fast algorithms for finding nearest common ancestors, SIAM J. on Comp. 13 (2): 338–355, 1984] Preprocessing Time vs Query Time ? nca(i, j) 13 4 7 1 6 11 8 2 3 5 11 Cartesian Tree [Vuillemin 1980] j 2 i 1 i j Discrete Range Maximum 1 2 3 4 5 6 7 8 9 10 11 13 max(i, j)

+ Cartesian Tree Construction Incremental construction left-to-right O(n) time (Φ = #nodes on rightmost path) 18 8 13 2 10 18 8 13 2 + 10 START HERE 18 ∙∙∙ 13 8 2 10

Reduction: NCA  1 Discrete Range Maximum nca(i, j) H Euler Tour A B C D E F J G K I E G j i C nca(i, j) i j Neighbours differ by 1 node H E B A D C F G J I K 1 2 3 4 5 depth 2 minimum depth

NCA on Perfect Binary Trees 1 2 3 4 5 = nca(11,21) i 10 11 2i 2i+1 20 21 22 23 11 = 10112 21 = 101012 nca(21,21) = 5 = 1012 = lcp( 10112 , 101012 ) longest common prefix msb = tabulation / int-to-float conversion / using multiplication... proc lcp(x, y) if y < x then swap (x, y) return x >> (msb(x XOR (y >> (msb(y)-msb(x))) position of most significant bit ≠ 0

drm(i, j) = min(righti(d), leftj(d)) d = msb(i XOR j) Discrete Range Minimum – Space O(n∙log n) words nca(i, j) 2 3 4 5 1 0 1 i ∙ ∙ ∙ j 1 2 3 4 5 1 3 2 d 5 Alternative solution: For each i store intervals of size 2^d only to the right and return min(right_i[d],right_{j-2^d+1}). righti leftj drm(i, j) = min(righti(d), leftj(d)) d = msb(i XOR j)

Blocked solution – Space O(n) words Top structure O(n/log n) elements Space O(n) Query O(1) 1 2 1 2 3 4 5 i j block of O(log n) elements 1 5 4 3 2 Wj (One for each j) Block query: j+1-msb(Wj AND ((1 << (j-i+1))-1)) General query: 1 top query + 2 bottom queries O(n) Preprocessing Time O(1) Query Time

O(n) Preprocessing Time O(1) Query Time Summary... General Discrete Range Searching i j 1 2 3 4 5 6 7 8 9 Cartesian Tree nca(i, j) 4 7 1 6 8 2 9 NCA j i Discrete Range Max on Depth Array 1 2 3 4 5 ”O(n∙log n)” solution on O(n/log n) blocks O(log n) size blocks O(n) Preprocessing Time O(1) Query Time

1d & 2D DRM Results Indexing Model (input accessible) Encoding Model (input not accessable) m = 1 1D 2n+o(n) bits, O(1) time [FH07] n/c bits  Ω(c) time [BDR10] n/c bits, O(c) time [BDR10] ≥ 2n - O(log n) bits 2n+o(n) bits, O(1) time [F10] 1 < m < n O(mnlog n) bits, O(1) time [AY10] O(mn) bits, O(1) time [BDR10] mn/c bits  Ω(c) time [BDR10] O(clog2 c) time [BDR10] O(clog c(loglog c)2) time [BDLRR12] Ω(mnlog m) bits [BDR10] O(mnlog n) bits, O(1) time [BDR10] O(mnlog m) bits, O(mn) time [BBD13] m = n squared Ω(mnlog n) bits [DLW09] FH07 = Fischer & Heun, ESCAPE 2007 DLW09 = Demaine, Landau & Weiman ICALP 2009 AY10 = Atallah, Yuan SODA 2010 F10 = Fischer STACS 2010 BDLRR12 = Brodal, Davoodi, Lewenstein, Raman, Rao ESA 2012 better upper or lower bound ?

DRM encoding - O(n) bits j A 1 B 2 C 3 D 4 E 5 F 6 G 7 H 8 I 9 J 10 K 11 4 7 1 6 11 2 13 5 8 3 j’th ”1” = select(j) nca(i, j) H Euler Tour Cartesian Tree A B C D E F J G K I E G j i C nca(i, j) node H E B A D C F G J I K 1 2 3 4 5 depth 2 minimum depth select(i) = i’th ”1” pi p pj 1 + - 4n bits rank(p) = drm(i,j) = #1 left of p depth = #+ - #- = min-prefix-sum(pi,pj)

Succinct data structures for DRM, O(n) bits α = ½log n bits i’th ”1” = select(i) p 1  1 B0 B1 B2 B3 … R1[i] = #1 in first i blocks (n/αlog n bits) Trank = rank inside block, table lookup (2α+log α log α bits) rank(p) = R1[└p/α┘] + Trank[B[└p/α┘], p mod α] α+log α bits i is in block B[b] leader[i] = is the ith ”1” the first ”1” in its block? (n bits) rankleader(i) = rank structure for leader array (O(n) bits) Rnonempty = index of nonempty blocks (n/αlog n bits) Tselect = select inside block, table lookup (2α+log αlog α bits) select(i) = αb + Tselect [B[b], i-rank(αb-1)] b = Rnonempty[rankleader(i)] min-prefix-sum(pi, pj) = α(bk-1)+dk b1 = └pi/α┘ b3 = └pj/α┘ b2 = drmPS(b1+1, b3-1) d1 = Tmps[B[b1], pi mod α, α-1] d2 = Tmps[B[b2], 0, α-1] d3 = Tmps[B[b3], 0, pj mod α] k = argmint=1..3 PS[bt-1]+Tps[B[bt], dt] PS[b] = #+ - #- for blocks B0..Bb (n/αlog n bits) Tps = #+ - #- for block prefix, table lookup (2α+log α(1+log α) bits) Tmps = index of minimum prefix sum #+ - #- inside range in a block, table lookup (2α+2log αlog α bits) MPS[b] = PS[b-1]+ Tmps[B[b], 0, α-1] (n/αlog n bits) drmMPS = drmin structure for MPS, O(n/α) words (O(n) bits) b1 b2 b3 MPS 1 3 2 d1=3 d3=1 pi d2=2 pj + - Bb1 Bb2 Bb3