1 Persistent data structures. 2 Ephemeral: A modification destroys the version which we modify. Persistent: Modifications are nondestructive. Each modification.

Slides:



Advertisements
Similar presentations
Two Segments Intersect?
Advertisements

Planar point location -- example
Nearest Neighbor Search
Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should.
Dynamic Planar Convex Hull Operations in Near- Logarithmic Amortized Time TIMOTHY M. CHAN.
I/O-Algorithms Lars Arge Fall 2014 September 25, 2014.
2/14/13CMPS 3120 Computational Geometry1 CMPS 3120: Computational Geometry Spring 2013 Planar Subdivisions and Point Location Carola Wenk Based on: Computational.
Brute-Force Triangulation
2/3/15CMPS 3130/6130 Computational Geometry1 CMPS 3130/6130 Computational Geometry Spring 2015 Triangulations and Guarding Art Galleries II Carola Wenk.
UNC Chapel Hill M. C. Lin Polygon Triangulation Chapter 3 of the Textbook Driving Applications –Guarding an Art Gallery –3D Morphing.
9/12/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Triangulations and Guarding Art Galleries II Carola Wenk.
Overlay of Two Subdivisions
Zoo-Keeper’s Problem An O(nlogn) algorithm for the zoo-keeper’s problem Sergei Bespamyatnikh Computational Geometry 24 (2003), pp th CGC Workshop.
1 Algorithmic Aspects of Searching in the Past Christine Kupich Institut für Informatik, Universität Freiburg Lecture 1: Persistent Data Structures Advanced.
External Memory Geometric Data Structures
Chapter 7 Data Structure Transformations Basheer Qolomany.
Intersections. Intersection Problem 3 Intersection Detection: Given two geometric objects, do they intersect? Intersection detection (test) is frequently.
17. Computational Geometry Chapter 7 Voronoi Diagrams.
Sorting Chapter Sorting Consider list x 1, x 2, x 3, … x n We seek to arrange the elements of the list in order –Ascending or descending Some O(n.
Multiversion Access Methods - Temporal Indexing. Basics A data structure is called : Ephemeral: updates create a new version and the old version cannot.
WS Prof. Dr. Th. Ottmann Algorithmentheorie 16 – Persistenz und Vergesslichkeit.
I/O-Algorithms Lars Arge Aarhus University February 27, 2007.
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.
Persistent Data Structures Computational Geometry, WS 2007/08 Lecture 12 Prof. Dr. Thomas Ottmann Khaireel A. Mohamed Algorithmen & Datenstrukturen, Institut.
Temporal Indexing MVBT. Temporal Indexing Transaction time databases : update the last version, query all versions Queries: “Find all employees that worked.
I/O-Algorithms Lars Arge University of Aarhus March 1, 2005.
Temporal Indexing MVBT. Temporal Indexing Transaction time databases : update the last version, query all versions Queries: “Find all employees that worked.
Amortized Analysis (chap. 17) Not just consider one operation, but a sequence of operations on a given data structure. Average cost over a sequence of.
I/O-Algorithms Lars Arge Spring 2009 March 3, 2009.
An almost linear fully dynamic reachability algorithm.
I/O-Algorithms Lars Arge Aarhus University March 5, 2008.
Space Efficient Point Location forTriangulations.
Point Location Computational Geometry, WS 2007/08 Lecture 5 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für.
I/O-Algorithms Lars Arge University of Aarhus March 7, 2005.
1 Geometric index structures April 15, 2004 Based on GUW Chapter , [Arge01] Sections 1, 2.1 (persistent B- trees), 3-4 (static versions.
1 Persistent data structures. 2 Ephemeral: A modification destroys the version which we modify. Persistent: Modifications are nondestructive. Each modification.
Lecture 6: Point Location Computational Geometry Prof. Dr. Th. Ottmann 1 Point Location 1.Trapezoidal decomposition. 2.A search structure. 3.Randomized,
The Potential Method. Deque with stacks size=7 13 S1S1 S2S2 push(x,D): push(x,S 1 ) push(2,D)
1 Abstract Data Types Queue + Dequeue Amortized analysis.
AALG, lecture 11, © Simonas Šaltenis, Range Searching in 2D Main goals of the lecture: to understand and to be able to analyze the kd-trees and.
1 Geometric Intersection Determining if there are intersections between graphical objects Finding all intersecting pairs Brute Force Algorithm Plane Sweep.
UNC Chapel Hill M. C. Lin Point Location Reading: Chapter 6 of the Textbook Driving Applications –Knowing Where You Are in GIS Related Applications –Triangulation.
1 B Trees - Motivation Recall our discussion on AVL-trees –The maximum height of an AVL-tree with n-nodes is log 2 (n) since the branching factor (degree,
UNC Chapel Hill M. C. Lin Line Segment Intersection Chapter 2 of the Textbook Driving Applications –Map overlap problems –3D Polyhedral Morphing.
External Memory Algorithms for Geometric Problems Piotr Indyk (slides partially by Lars Arge and Jeff Vitter)
14/13/15 CMPS 3130/6130 Computational Geometry Spring 2015 Windowing Carola Wenk CMPS 3130/6130 Computational Geometry.
BackTracking CS335. N-Queens The object is to place queens on a chess board in such as way as no queen can capture another one in a single move –Recall.
Lars Arge Presented by Or Ozery. I/O Model Previously defined: N = # of elements in input M = # of elements that fit into memory B = # of elements per.
Computational Geometry Piyush Kumar (Lecture 10: Point Location) Welcome to CIS5930.
Sorting Chapter Sorting Consider list x 1, x 2, x 3, … x n We seek to arrange the elements of the list in order –Ascending or descending Some O(n.
PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting.
February 17, 2005Lecture 6: Point Location Point Location (most slides by Sergi Elizalde and David Pritchard)
Final Review Chris and Virginia. Overview One big multi-part question. (Likely to be on data structures) Many small questions. (Similar to those in midterm.
Temporal Indexing MVBT. Temporal Indexing Transaction time databases : update the last version, query all versions Queries: “Find all employees that worked.
Polygon Triangulation
Data Structures and Algorithm Analysis Dr. Ken Cosh Linked Lists.
Michal Balas1 I/O-efficient Point Location using Persistent B-Trees Lars Arge, Andrew Danner, and Sha-Mayn Teh Department of Computer Science, Duke University.
Computational Geometry
BackTracking CS255.
Persistent Data Structures (Version Control)
Temporal Indexing MVBT.
Temporal Indexing MVBT.
Abstract Data Types Stack, Queue Amortized analysis
Segment tree and Interval Tree
Craig Schroeder October 26, 2004
Persistent deques.
Abstract Data Types Stack, Queue Amortized analysis
Abstract Data Types Stack, Queue Amortized analysis
Overlay of Two Subdivisions
Abstract Data Types Stack, Queue Amortized analysis
Presentation transcript:

1 Persistent data structures

2 Ephemeral: A modification destroys the version which we modify. Persistent: Modifications are nondestructive. Each modification creates a new version. All version coexist. We have a big data structure that represent all versions

3 Partially persistent: Can access any version, but can modify only the most recent one. V1 V2 V3 V4 V5

4 fully persistent: Can access and modify any version any number of times. V1 V2 V3 V4 V5

5 confluently persistent: fully persistent and there is an operation that combines two or more versions to one new version. V1 V2 V3 V4 V5

6 Purely functional: You are not allowed to change a field in a node after it is initialized. This is everything you can do in a pure functional programming language

7 Example -- stacks Two operations S’ = push(x,S) (x,S’) = pop(S) y S x S’ S’ = push(x,S) S’’ = push(z,S’) z S’’ (y,S 3 ) = pop( S) S3S3 Stacks are automatically fully persistent. S S’ s’’ S 3

8 Example -- queues Two operations Q’ = inject(x,Q) (x,Q’) = pop(Q) Q y Q’ = inject(x,Q) (y,Q 3 ) = pop( Q’’) Q Q’’ = inject(z,Q’) Q’ x Q’’ z Q3Q3 Q3Q3 We have partial persistent, We never want to store two different value in the same field How do we make the queue fully persistent ?

9 Example -- double ended queues four operations Q’ = inject(x,Q) (x,Q’) = eject(Q) Q’ = push(x,Q) (x,Q’) = pop(Q) (x,Q’) = eject(Q) Q’’ = inject(z,Q’) x Here its not even obvious how to get partial persistence ? Q Q Q’

10 Maybe we should use stacks Stacks are easy. We know how to simulate queues with stacks. So we should be able to get persistent queues this way... inject eject push pop When one of the stacks gets empty we split the other eject

11 Deque by stack simulation (ephemeral analysis)  = | |S l | - |S r | | Each operation changes the potential by O(1) The amortized cost of the reverse is eject In a persistent setting it is not clear that this potential is well defined

12 Deque by stack simulation (partial persistence)  = | |S l | - |S r | | Where S is the “live” stack, the one which we can modify Everything still works eject When we do the reversal in order not to modify any other stack we copy the nodes !

13 Deque by stack simulation (full persistence).... Can repeat the expensive operation over and over again.... or A sequence of n operations that costs  (n 2 ) eject

14 Summary so far Stacks are automatically fully persistent Got partially persistent queues in O(1) time per pop/inject Got partially persistent deques in O(1) amortized time per operation How about fully persistent queues ? Partially persistent search trees, other data structures ? Can we do something general ?

15 Some easy observations You could copy the entire data structure before doing the operation:  (n) time per update,  (nm) space. You could also refrain from doing anything just keep a log of the updates. When accessing version i perform first the i updates in order to obtain version i:  (i) time per access, O(m) space. You could use a hybrid approach that would store the entire sequence of updates and in addition every k th version for some suitable k. Either the space or the access time blows up by a factor of  m. Can you do things more efficiently ?

16 How about search trees ? All modifications occur on a path. So it suffices to copy one path. This is the path copying method.

17 Example -- path copying

18 Example -- path copying

19 Path copying -- analysis O(log n) time for update and access O(log n) space per update Want the space bound to be proportional to the number of field modifications that the ephemeral update did. In case of search trees we want the space consumption of update to be O(1) (at least amortized). Gives fully persistent search trees!

20 Application -- planar point location Suppose that the Euclidian plane is subdivided into polygons by n line segments that intersect only at their endpoints. Given such polygonal subdivision and an on-line sequence of query points in the plane, the planar point location problem, is to determine for each query point the polygon containing it. Measure an algorithm by three parameters: 1) The preprocessing time. 2) The space required for the data structure. 3) The time per query.

21 Planar point location -- example

22 Planar point location -- example

23 Solving planar point location (Cont.) Partition the plane into vertical slabs by drawing a vertical line through each endpoint. Within each slab the lines are totally ordered. Allocate a search tree per slab containing the lines at the leaves with each line associate the polygon above it. Allocate another search tree on the x-coordinates of the vertical lines

24 Solving planar point location (Cont.) To answer query first find the appropriate slab Then search the slab to find the polygon

25 Planar point location -- example

26 Planar point location -- analysis Query time is O(log n) How about the space ?  (n 2 ) And so could be the preprocessing time

27 Planar point location -- bad example Total # lines O(n), and number of lines in each slab is O(n).

28 Planar point location & persistence So how do we improve the space bound ? Key observation: The lists of the lines in adjacent slabs are very similar. Create the search tree for the first slab. Then obtain the next one by deleting the lines that end at the corresponding vertex and adding the lines that start at that vertex How many insertions/deletions are there alltogether ? 2n

29 Planar point location & persistence (cont) Updates should be persistent since we need all search trees at the end. Partial persistence is enough Well, we already have the path copying method, lets use it. What do we get ? O(nlogn) space and O(nlog n) preprocessing time. We shall improve the space bound to O(n).

30 Making data structures persistent (DSST 89) We will show a general technique to make data structures partially and later fully persistent. The time penalty of the transformation would be O(1) per elementary access and update step. In particular, this would give us an O(n) space solution to the planar point location problem The space penalty of the transformation would be O(1) per update step.