Persistent Data Structures and Planar Point Location



Similar documents
Persistent Data Structures

Persistent Binary Search Trees

Analysis of Algorithms I: Binary Search Trees

A binary heap is a complete binary tree, where each node has a higher priority than its children. This is called heap-order property

EE602 Algorithms GEOMETRIC INTERSECTION CHAPTER 27

Complexity of Union-Split-Find Problems. Katherine Jane Lai

Binary Search Trees. Data in each node. Larger than the data in its left child Smaller than the data in its right child

Binary Heap Algorithms

Vector storage and access; algorithms in GIS. This is lecture 6

Binary Heaps * * * * * * * / / \ / \ / \ / \ / \ * * * * * * * * * * * / / \ / \ / / \ / \ * * * * * * * * * *

Learning Outcomes. COMP202 Complexity of Algorithms. Binary Search Trees and Other Search Trees

External Memory Geometric Data Structures

Previous Lectures. B-Trees. External storage. Two types of memory. B-trees. Main principles

INTERSECTION OF LINE-SEGMENTS

Binary Search Trees. A Generic Tree. Binary Trees. Nodes in a binary search tree ( B-S-T) are of the form. P parent. Key. Satellite data L R

Sorting revisited. Build the binary search tree: O(n^2) Traverse the binary tree: O(n) Total: O(n^2) + O(n) = O(n^2)

Shortest Inspection-Path. Queries in Simple Polygons

5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

B-Trees. Algorithms and data structures for external memory as opposed to the main memory B-Trees. B -trees

The LCA Problem Revisited

Binary Heaps. CSE 373 Data Structures

CS711008Z Algorithm Design and Analysis

Data Structures Fibonacci Heaps, Amortized Analysis

IE 680 Special Topics in Production Systems: Networks, Routing and Logistics*

MATHEMATICAL ENGINEERING TECHNICAL REPORTS. The Best-fit Heuristic for the Rectangular Strip Packing Problem: An Efficient Implementation

Converting a Number from Decimal to Binary

Lecture 2 February 12, 2003

Computational Geometry. Lecture 1: Introduction and Convex Hulls

root node level: internal node edge leaf node Data Structures & Algorithms McQuain

Journal of Systems Architecture

From Last Time: Remove (Delete) Operation

Binary Search Trees 3/20/14

An Evaluation of Self-adjusting Binary Search Tree Techniques

A binary search tree is a binary tree with a special property called the BST-property, which is given as follows:

A Comparison of Dictionary Implementations

Outline BST Operations Worst case Average case Balancing AVL Red-black B-trees. Binary Search Trees. Lecturer: Georgy Gimel farb

Lecture 6: Binary Search Trees CSCI Algorithms I. Andrew Rosenberg

Home Page. Data Structures. Title Page. Page 1 of 24. Go Back. Full Screen. Close. Quit

CSE 326: Data Structures B-Trees and B+ Trees

How To Create A Tree From A Tree In Runtime (For A Tree)

6 March Array Implementation of Binary Trees

Data Warehousing und Data Mining

Scan-Line Fill. Scan-Line Algorithm. Sort by scan line Fill each span vertex order generated by vertex list

Binary Search Trees CMPSC 122

Analysis of Algorithms, I

Point Location. Preprocess a planar, polygonal subdivision for point location queries. p = (18, 11)

Data storage Tree indexes

Chapter 6: Physical Database Design and Performance. Database Development Process. Physical Design Process. Physical Database Design

Algorithms Chapter 12 Binary Search Trees

A Note on Maximum Independent Sets in Rectangle Intersection Graphs

Line Segment Intersection

Cpt S 223. School of EECS, WSU

Merkle Hash Trees for Distributed Audit Logs

Rotation Operation for Binary Search Trees Idea:

The Cost of Offline Binary Search Tree Algorithms and the Complexity of the Request Sequence

Chapter 13: Query Processing. Basic Steps in Query Processing

TREE BASIC TERMINOLOGIES

Introduction Advantages and Disadvantages Algorithm TIME COMPLEXITY. Splay Tree. Cheruku Ravi Teja. November 14, 2011

Full and Complete Binary Trees

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

Algorithms. Algorithms GEOMETRIC APPLICATIONS OF BSTS. 1d range search line segment intersection kd trees interval search trees rectangle intersection

Chapter 14 The Binary Search Tree

CMPSCI611: Approximating MAX-CUT Lecture 20

Big Data and Scripting. Part 4: Memory Hierarchies

Data Structures. Jaehyun Park. CS 97SI Stanford University. June 29, 2015

Exam study sheet for CS2711. List of topics

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) Total 92.

Universal hashing. In other words, the probability of a collision for two different keys x and y given a hash function randomly chosen from H is 1/m.

Symbol Tables. Introduction

Operations: search;; min;; max;; predecessor;; successor. Time O(h) with h height of the tree (more on later).

Sample Questions Csci 1112 A. Bellaachia

Shortest Path Algorithms

A Fast Algorithm For Finding Hamilton Cycles

Data Structure [Question Bank]

Disjoint Compatible Geometric Matchings

Outline. Introduction Linear Search. Transpose sequential search Interpolation search Binary search Fibonacci search Other search techniques

Tables so far. set() get() delete() BST Average O(lg n) O(lg n) O(lg n) Worst O(n) O(n) O(n) RB Tree Average O(lg n) O(lg n) O(lg n)

V. Adamchik 1. Graph Theory. Victor Adamchik. Fall of 2005

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:

CSC2420 Fall 2012: Algorithm Design, Analysis and Theory

Binary Search Tree Intro to Algorithms Recitation 03 February 9, 2011

CIS 700: algorithms for Big Data

Quiz 4 Solutions EECS 211: FUNDAMENTALS OF COMPUTER PROGRAMMING II. 1 Q u i z 4 S o l u t i o n s

File System Management

- Easy to insert & delete in O(1) time - Don t need to estimate total memory needed. - Hard to search in less than O(n) time

Motivation Suppose we have a database of people We want to gure out who is related to whom Initially, we only have a list of people, and information a

Storing a Collection of Polygons Using Quadtrees

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,

Arrangements And Duality

Data Structures. Level 6 C Module Descriptor

Binary Trees and Huffman Encoding Binary Search Trees

Seminar. Path planning using Voronoi diagrams and B-Splines. Stefano Martina

Colored Range Searching on Internal Memory

Transcription:

Persistent Data Structures and Planar Point Location Inge Li Gørtz

Persistent Data Structures Ephemeral Partial persistence Full persistence Confluent persistence V1 V1 V1 V1 V2 q ue V2 V2 V5 V2 V4 V4 r i e s V4 V7 V3 V4 V6 V8 update and query all versions V6 V7 V3 V5 V3 V3 V5 update and query last version V5 update update, query and combine all versions

Persistent Data Structures Ephemeral data structures. A modification destroys the old version. Persistent data structures. Modifications nondestructive. Each modification creates a new version. All versions coexists. Partially persistent data structures. Can access all versions, but only update the latest version. Fully persistent data structures. Can access and modify all versions (branching). An update operation only operates on a single version at a time (cannot combine several versions). Confluent persistent data structures. Can access and modify all versions and combine versions into new versions. Functional data structures. Cannot change any nodes, only create new ones.

Simple methods for making data structures persistent Structure-copying method. Create a copy of the data structure each time it is changed. Slowdown of Ω(n) time and space per update to a data structure of size n. Store a log-file of all updates. In order to access version i, first carry out i updates, starting with the initial structure, and generate version i. Overhead of Ω(i) time per access, O(1) space and time per update. Hybrid-method. Store the complete sequence of updates and additionally each k-th version for a suitably chosen k. Result: Any choice of k causes blowup in either storage space or access time.

Overview Partial persistence. Fat node method. Node copying Full persistence. Main idea. Algorithmic applications

Partial Persistence Fat node method

Fat node method Associate set c(x) for each location in memory x. c(x)={<t,v>: x modified in version t, x has value v after construction of version t} x D(x): data structure containing c(x) Query q(t,x): Find largest version number t in t such that t t. Return value associated with t in D(x). Update (create new version m): If memory locations x1,...,xk modified to the values v1,...vk: Insert <m,vi> in D(xi).

Fat node method Implementation of D(x): Balanced binary search tree: query O(log c(x) ) = O(log m), m number of versions. Update: O(1) Extra space: O(1) y-fast trie: query: O(loglog m) update: expected O(loglog m) Extra space: O(1)

Fat node method Linked data structures: each pointer field store many time value pairs. new node created by ephemeral update: create new node and mark all fields with version i. Auxiliary array keep pointer to root of each version. 2 4 7 14 Value 10 2

Fat node method example root 13 5 4 1 1 2 3. 20 2 2 3 4 5 3 5 21 4. 4 5 22 5 5

Fat node method Driscoll, Sarnak, Sleator, Tarjan, 1989. Any data structure can be made partially persistent with slowdown O(log m) for queries and O(1) for updates. The space cost is O(1) for each ephemeral memory modification. Any data structure can be made partially persistent on a RAM with slowdown O(loglog m) for queries and expected slowdown O(loglog m) for updates. The space cost is O(1) for each ephemeral memory modification

Partial Persistence Node copying method

Node copying method Linked data structure with bounded indegree p, p = O(1). Each node has p predecessor pointers + p + 1 extra fields. Auxiliary array to keep pointer to root of each version (field name, version)

Partially persistent balanced search trees via node copying Suffices to allow one extra pointer field in each node Each extra pointer is tagged with a version number and a field name. When ephemeral update allocates a new node: allocate a new node as well. When ephemeral update changes a pointer field: if the extra pointer is empty use it, otherwise copy the node. Try to store pointer to the new copy in its parent. If the extra pointer at the parent is occupied copy the parent and continue going up this way. Maintain array of roots indexed by timestamp. Value left 4

Node copying method example 1 2 3 4 13 13 R 2 20 20 L 3 14 28

Partially persistent BST with node copying Analysis: Time slowdown: access: O(1) updates: O(1) amortized Extra space: O(1) amortized O(1) for new nodes also created by ephemeral data structure O(1) amortized space for nodes created when a node is full. Proof uses potential analysis (next time).

Partially Persistent Data Structures Driscoll, Sarnak, Sleator, Tarjan, 1989. Any bounded-degree linked data structure can be made partially persistent with (worst-case) slowdown O(1) for queries, amortized slowdown O(1) for updates, and amortized space cost O(1) per memory modification.

Full Persistence Fat node method

Version tree Version tree: partial order. V1 Tree color problem: AddLeaf(v, c): Add leaf u as child of v, with color(u)=c. V2 V5 Lookup(v, c): Find nearest ancestor of v with color c. V3 V4 V6 V8 Fully persistent array: V7 Store(A, i, x, t): Set A[i]=x at time t ~ AddLeaf(t, i), value v = x. Access(A, i, t): Lookup value A[i] at time t ~ Lookup(t, i)

Version tree and version list Euler tour: L(T) = (v1, v2, v3, v7, v7, v3, v4, v4, v6, v6, v2, v5, v8, v8, v5, v1 ) Partition list for each color: V1 L(1) = (v1, v2, v3, v7, v7, v3, v4, v4 ), (v6, v6 ), (v2, v5, v8, v8, v5, v1 ) V2 V5 L(2) = (v1), (v2), (v3, v7, v7, v3 ), (v4, v4 ), (v6, v6, v2, v5, v8, v8, v5, v1 ) V3 V4 V6 V8 L(3) = (v1, v2, v3, v7, v7, v3, v4, v4, v6, v6, v2 ), (v5), (v8, v8 ), (v5, v1 ) V7 Predecessor data structure for each color to find right sublist. Maintaining order in a list problem: O(1) time.

Fully Persistent Data Structures Driscoll, Sarnak, Sleator, Tarjan, 1989. Any data structure can be made fully persistent with slowdown O(log m) for both queries and updates. The space cost is O(1) for each ephemeral memory modification. Any bounded-degree linked data structure can be made fully persistent with (worst-case) slowdown O(1) for queries, amortized slowdown O(1) for updates, and amortized space cost O(1) per memory modification. Dietz, 1989. Any data structure can be made fully persistent on a RAM with slowdown O(loglog m) for queries and expected slowdown O(loglog m) for updates. The space cost is O(1) for each ephemeral memory modification.

Algorithmic Applications

Planar Point Location Planar point location. Euclidean plane subdivided into polygons by n line segments that intersect only at their endpoints. Query: given a query point p determine which polygon that contains p. Measure algorithm by three parameters: Preprocessing time Query time Space

Planar point location: Example From slides by H. Kaplan

Planar point location: Example From slides by H. Kaplan 25

Planar Point Location Within each slab the lines are totally ordered. Search tree per slab containing the lines at the leaves with each line associate the polygon above it. Another search tree on the x-coordinates of the vertical lines. query find appropriate slab search the search tree of the slab to find the polygon

Planar Point Location One search tree for each slab: Query time: O(log n) Space: Ω(n 2 ) Total # lines O(n), and number of lines in each slab is O(n).

Planar point location: Improve space bound Key observation: The lists of the lines in adjacent slabs are very similar. Create the search tree for the first slab. Obtain the next one by deleting the lines that end at the corresponding vertex and adding the lines that start at that vertex. Number of insertions/deletions? 2n Use partially persistent search tree. x- axis is time.

Planar Point Location Sarnak and Tarjan. Sweep line + partially persistent binary search tree: Preprocessing time: O(n log n) Query time: O(log n) Space O(n) To get linear space: Balanced binary search tree with worst case O(1) memory modifications per update.