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

Similar documents
Persistent Data Structures and Planar Point Location

Persistent Data Structures

Persistent Binary Search Trees

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

Data Structures Fibonacci Heaps, Amortized Analysis

Confluently Persistent Tries for Efficient Version Control

Converting a Number from Decimal to Binary

Analysis of Algorithms I: Binary Search Trees

Shortest Inspection-Path. Queries in Simple Polygons

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

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.

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

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

External Memory Geometric Data Structures

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

A Comparison of Dictionary Implementations

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

Ordered Lists and Binary Trees

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

EE602 Algorithms GEOMETRIC INTERSECTION CHAPTER 27

Shortest Path Algorithms

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

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

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

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

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

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

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

From Last Time: Remove (Delete) Operation

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

Lecture 2 February 12, 2003

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

Computational Geometry. Lecture 1: Introduction and Convex Hulls

Symbol Tables. Introduction

Journal of Systems Architecture

Data Structure [Question Bank]

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)

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

Data Structures. Level 6 C Module Descriptor

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

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

Binary Search Trees 3/20/14

INTERSECTION OF LINE-SEGMENTS

Data Warehousing und Data Mining

TREE BASIC TERMINOLOGIES

Binary Heap Algorithms

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.

Binary Search Trees CMPSC 122

Data Structures and Algorithms

Data storage Tree indexes

An Evaluation of Self-adjusting Binary Search Tree Techniques

- 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

A Note on Maximum Independent Sets in Rectangle Intersection Graphs

Dynamic 3-sided Planar Range Queries with Expected Doubly Logarithmic Time

Rotation Operation for Binary Search Trees Idea:

The LCA Problem Revisited

Internet Packet Filter Management and Rectangle Geometry

CS711008Z Algorithm Design and Analysis

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

S. Muthusundari. Research Scholar, Dept of CSE, Sathyabama University Chennai, India Dr. R. M.

Partially Persistent Data Structures of Bounded Degree with Constant Update Time

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

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

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

Chapter 13: Query Processing. Basic Steps in Query Processing

Exam study sheet for CS2711. List of topics

Questions 1 through 25 are worth 2 points each. Choose one best answer for each.

Binary Heaps. CSE 373 Data Structures

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

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

Algorithms Chapter 12 Binary Search Trees

Arrangements And Duality

Line Segment Intersection

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

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

Towards TCAM-based Scalable Virtual Routers

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

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

6 March Array Implementation of Binary Trees

Introduction to Data Structures and Algorithms

Disjoint Compatible Geometric Matchings

Full and Complete Binary Trees

APP INVENTOR. Test Review

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:

Analysis of Algorithms, I

Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C

CMPSCI611: Approximating MAX-CUT Lecture 20

File System Management

DATABASE DESIGN - 1DL400

Sample Questions Csci 1112 A. Bellaachia

Abstract Data Type. EECS 281: Data Structures and Algorithms. The Foundation: Data Structures and Abstract Data Types

ONLINE DEGREE-BOUNDED STEINER NETWORK DESIGN. Sina Dehghani Saeed Seddighin Ali Shafahi Fall 2015

Merkle Hash Trees for Distributed Audit Logs

Triangulation by Ear Clipping

The Butterfly, Cube-Connected-Cycles and Benes Networks

CIS 700: algorithms for Big Data

Big Data and Scripting. Part 4: Memory Hierarchies

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

Longest Common Extensions via Fingerprinting

6. Standard Algorithms

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 A(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 A(x). Update (create new version m): If memory locations x1,...,xk modified to the values v1,...vk: Insert <m,vi> in A(xi).

Fat node method Implementation of A(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 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 Path copying method

Path copying method Partially persistent search tree: All modifications occur on a path Enough to copy path Make a copy of the node before changing it to point to the new child. Cascade the change back to root. Restructuring costs O(height_of_tree) per update operation Every modification creates a new root Maintain an array of roots indexed by timestamp. Analysis. Partially persistent balanced binary search tree with O(log n) time per update and query, and O(log n) space per update.

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 Here it suffices to allow one extra pointer field in each node Each extra pointer is tagged with a version number and a field name. When the ephemeral update allocates a new node you allocate a new node as well. When the 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.

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 23

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.