1 Nearest Common Ancestors (NCA) Discrete Range Maximum 1234567891011 4716 6213583 4 7 1 6 11 6 8 2 35 Cartesian Tree [Vuillemin 1980] i j max(i, j) i.

Slides:



Advertisements
Similar presentations
Fast Algorithms for Finding Nearest Common Ancestors Dov Harel and Robert Endre Tarjan Fast Algorithms for Finding Nearest Common Ancestors SIAM J. COMPUT.
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.
7-Segment Displays Lecture L6.1 Section 6.3. Turning on an LED.
Minimum Spanning Trees (MSTs) Prim's Algorithm For each vertex not in the tree, keep track of the lowest cost edge that would connect it to the tree This.
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.
Suffix Sorting & Related Algoritmics Martin Farach-Colton Rutgers University USA.
Suffix Trees Suffix trees Linearized suffix trees Virtual suffix trees Suffix arrays Enhanced suffix arrays Suffix cactus, suffix vectors, …
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.
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.
Update 1 Persistent Data Structures (Version Control) v0v0 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 Ephemeral query v0v0 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 Partial persistence.
Lowest common ancestors. Write an Euler tour of the tree LCA(1,5) = 3 Shallowest node.
Heapsort. 2 Why study Heapsort? It is a well-known, traditional sorting algorithm you will be expected to know Heapsort is always O(n log n) Quicksort.
I/O-Efficient Structures for Orthogonal Range Max and Stabbing Max Queries Second Year Project Presentation Ke Yi Advisor: Lars Arge Committee: Pankaj.
6/26/2015 7:13 PMTries1. 6/26/2015 7:13 PMTries2 Outline and Reading Standard tries (§9.2.1) Compressed tries (§9.2.2) Suffix tries (§9.2.3) Huffman encoding.
Improvements on the Range-Minimum-Query- Problem
E.G.M. Petrakissearching1 Searching  Find an element in a collection in the main memory or on the disk  collection: (K 1,I 1 ),(K 2,I 2 )…(K N,I N )
Lecture 11 : More Geometric Data Structures Computational Geometry Prof. Dr. Th. Ottmann 1 Geometric Data Structures 1.Rectangle Intersection 2.Segment.
CSC 3323 Notes – Introduction Algorithm Analysis.
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,
Heapsort Based off slides by: David Matuszek
Computer Science and Software Engineering University of Wisconsin - Platteville 12. Heap Yan Shi CS/SE 2630 Lecture Notes Partially adopted from C++ Plus.
UNC Chapel Hill M. C. Lin Orthogonal Range Searching Reading: Chapter 5 of the Textbook Driving Applications –Querying a Database Related Application –Crystal.
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.
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.
The LCA Problem Revisited Michael A.Bender & Martin Farach-Colton Presented by: Dvir Halevi.
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
Constant-Time LCA Retrieval Presentation by Danny Hermelin, String Matching Algorithms Seminar, Haifa University.
Pawe ł Gawrychowski* and Pat Nicholson** *University of Warsaw **Max-Planck-Institut für Informatik.
Suffix trees. Trie A tree representing a set of strings. a b c e e f d b f e g { aeef ad bbfe bbfg c }
1 Lower Bound on Comparison-based Search We have now covered lots of searching methods –Contiguous Data (Arrays) Sequential search Binary Search –Dynamic.
Huffman’s Algorithm 11/02/ Weighted 2-tree A weighted 2-tree T is an extended binary tree with n external nodes and each of the external nodes is.
Main Index Contents 11 Main Index Contents Complete Binary Tree Example Complete Binary Tree Example Maximum and Minimum Heaps Example Maximum and Minimum.
1 Fat heaps (K & Tarjan 96). 2 Goal Want to achieve the performance of Fibonnaci heaps but on the worst case. Why ? Theoretical curiosity and some applications.
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.
ProblemData StructuresLower Bound Preprocess a set of N 3-dimensional points into an I/O-efficient data structure, such that all points inside an axis.
1 the BSTree class  BSTreeNode has same structure as binary tree nodes  elements stored in a BSTree are a key- value pair  must be a class (or a struct)
Navigation Piles with Applications to Sorting, Priority Queues, and Priority Deques Jyrki Katajainen and Fabio Vitale Department of Computing, University.
Discrete Methods in Mathematical Informatics Kunihiko Sadakane The University of Tokyo
Succinct Data Structures
School of Computing Clemson University Fall, 2012
Succinct Data Structures
Data Structures: Disjoint Sets, Segment Trees, Fenwick Trees
Succinct Data Structures
List Order Maintenance
Two equivalent problems
Persistent Data Structures (Version Control)
Ariel Rosenfeld Bar-Ilan Uni.
Data Structures: Segment Trees, Fenwick Trees
Fast Trie Data Structures
Minimum Spanning Tree Verification
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.
Topic 5: Heap data structure heap sort Priority queue
Aggregate-Max Nearest Neighbor Searching in the Plane
Find the value of g. Find the value of h. 105° h g 75°
Discrete Range Maximum
We have the following incomplete B&B tree:
Advanced Encryption Standard (AES)
Presentation transcript:

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

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

A B C D E F J G KI 3 Reduction: NCA   1 Discrete Range Maximum Euler Tour HEBABDCDBEFGFEHJIJKJH node depth i j nca(i, j) E G C j i 2 minimum depth nca(i, j) H

4 NCA on Perfect Binary Trees i 2i2i2i = nca(11,21) 11 = = nca(21,21) = 5 = = lcp( , ) longest common prefix 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

5 Discrete Range Mimimum – Space O(n∙log n) words d j 0 1 i ∙ ∙ ∙ right i left j drm(i, j) = min(right i (d), left j (d)) d = msb(i XOR j) nca(i, j)

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

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

1d & 2D DRM Results better upper or lower bound ? 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 < n1 < 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  log 2 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] O(mn  log n) bits, O(1) time [AY10]

A B C D E F J G KI 9 DRM encoding - O(n) bits Euler Tour HEBABDCDBEFGFEHJIJKJH node depth i j nca(i, j) E G C 2 minimum depth nca(i, j) H A1A1 B2B2 C3C3 D4D4 E5E5 F6F6 G7G7 H8H8 I9I9 J 10 K Cartesian Tree depth = # + - # - = min-prefix-sum(p i,p j ) j’th ”1” = select(j) 4n bits rank(p) = drm(i,j) = # 1 left of p p select(i) = i’th ”1” pipi pjpj i j

10 Succinct data structures for DRM, O(n) bits i’th ”1” = select(i) rank(p) = R 1 [ └ p/α ┘ ] + T rank [B[ └ p/α ┘ ], p mod α] p B0B0 B1B1 B2B2 α = ½  log n bits α+log α bits R 1 [i] = # 1 in first i blocks (n/α  log n bits) T rank = rank inside block, table lookup (2 α+log α  log α bits) B3B3 … select(i) = αb + T select [B[b], i-rank(αb-1)] b = R nonempty [rank leader (i)] i is in block B[b] leader[i] = is the ith ”1” the first ”1” in its block? (n bits) rank leader (i) = rank structure for leader array (O(n) bits) R nonempty = index of nonempty blocks (n/α  log n bits) T select = select inside block, table lookup (2 α+log α  log α bits) 0 1  min-prefix-sum(p i, p j ) = α(b k -1)+d k b 1 = └ p i /α ┘ b 3 = └ p j /α ┘ b 2 = drm PS (b 1 +1, b 3 -1) d 1 = T mps [B[b 1 ], p i mod α, α-1] d 2 = T mps [B[b 2 ], 0, α-1] d 3 = T mps [B[b 3 ], 0, p j mod α] k = argmin t=1..3 PS[b t -1]+T ps [B[b t ], d t ] PS[b] = # + - # - for blocks B 0..B b (n/α  log n bits) T ps = # + - # - for block prefix, table lookup (2 α+log α  (1+log α) bits) T mps = index of minimum prefix sum # + - # - inside range in a block, table lookup (2 α+2log α  log α bits) MPS[b] = PS[b-1]+ T mps [B[b], 0, α-1] (n/α  log n bits) drm MPS = drmin structure for MPS, O(n/α) words (O(n) bits) Bb1Bb1 Bb3Bb3 Bb2Bb2 b2b2 pipi pjpj b1b1 b3b3 d 1 =3 d 2 =2 d 3 =1 MPS