Planar point location -- example

Slides:



Advertisements
Similar presentations
Orthogonal range searching. The problem (1-D) Given a set of points S on the line, preprocess them to build structure that allows efficient queries of.
Advertisements

I/O-Algorithms Lars Arge Fall 2014 September 25, 2014.
1 Persistent data structures. 2 Ephemeral: A modification destroys the version which we modify. Persistent: Modifications are nondestructive. Each modification.
B+-Trees (PART 1) What is a B+ tree? Why B+ trees? Searching a B+ tree
1 Algorithmic Aspects of Searching in the Past Christine Kupich Institut für Informatik, Universität Freiburg Lecture 1: Persistent Data Structures Advanced.
Chapter 7 Data Structure Transformations Basheer Qolomany.
Indexes. Primary Indexes Dense Indexes Pointer to every record of a sequential file, (ordered by search key). Can make sense because records may be much.
Indexes. Primary Indexes Dense Indexes Pointer to every record of a sequential file, (ordered by search key). Can make sense because records may be much.
COMP 451/651 Indexes Chapter 1.
Multiversion Access Methods - Temporal Indexing. Basics A data structure is called : Ephemeral: updates create a new version and the old version cannot.
A balanced life is a prefect life.
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.
1 B trees Nodes have more than 2 children Each internal node has between k and 2k children and between k-1 and 2k-1 keys A leaf has between k-1 and 2k-1.
Chapter 9 of DBMS First we look at a simple (strawman) approach (ISAM). We will see why it is unsatisfactory. This will motivate the B+Tree Read 9.1 to.
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.
Temporal Indexing MVBT. Temporal Indexing Transaction time databases : update the last version, query all versions Queries: “Find all employees that worked.
BST Data Structure A BST node contains: A BST contains
Fully Persistent B-Trees 23 rd Annual ACM-SIAM Symposium on Discrete Algorithms, Kyoto, Japan, January 18, 2012 Gerth Stølting Brodal Konstantinos Tsakalidis.
Trees and Red-Black Trees Gordon College Prof. Brinton.
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Part B Part A:  Index Definition in SQL  Ordered Indices  Index Sequential.
1 Persistent data structures. 2 Ephemeral: A modification destroys the version which we modify. Persistent: Modifications are nondestructive. Each modification.
1 Indexing Structures for Files. 2 Basic Concepts  Indexing mechanisms used to speed up access to desired data without having to scan entire.
Primary Indexes Dense Indexes
Data Structures Using C++ 2E Chapter 11 Binary Trees and B-Trees.
Homework #3 Due Thursday, April 17 Problems: –Chapter 11: 11.6, –Chapter 12: 12.1, 12.2, 12.3, 12.4, 12.5, 12.7.
1 CS 728 Advanced Database Systems Chapter 17 Database File Indexing Techniques, B- Trees, and B + -Trees.
0 Course Outline n Introduction and Algorithm Analysis (Ch. 2) n Hash Tables: dictionary data structure (Ch. 5) n Heaps: priority queue data structures.
CHAPTER 71 TREE. Binary Tree A binary tree T is a finite set of one or more nodes such that: (a) T is empty or (b) There is a specially designated node.
Database Management 8. course. Query types Equality query – Each field has to be equal to a constant Range query – Not all the fields have to be equal.
Data Structures - CSCI 102 Binary Tree In binary trees, each Node can point to two other Nodes and looks something like this: template class BTNode { public:
Chapter 19: Binary Trees. Objectives In this chapter, you will: – Learn about binary trees – Explore various binary tree traversal algorithms – Organize.
CSE AU B-Trees1 B-Trees CSE 373 Data Structures.
© 2011 Pearson Addison-Wesley. All rights reserved 11 B-1 Chapter 11 (continued) Trees.
Multi-way Trees. M-way trees So far we have discussed binary trees only. In this lecture, we go over another type of tree called m- way trees or trees.
Binary Trees, Binary Search Trees RIZWAN REHMAN CENTRE FOR COMPUTER STUDIES DIBRUGARH UNIVERSITY.
2-3 Trees Extended tree.  Tree in which all empty subtrees are replaced by new nodes that are called external nodes.  Original nodes are called internal.
Indexing and hashing Azita Keshmiri CS 157B. Basic concept An index for a file in a database system works the same way as the index in text book. For.
CS201: Data Structures and Discrete Mathematics I Hash Table.
Oct 26, 2001CSE 373, Autumn A Forest of Trees Binary search trees: simple. –good on average: O(log n) –bad in the worst case: O(n) AVL trees: more.
Indexes. Primary Indexes Dense Indexes Pointer to every record of a sequential file, (ordered by search key). Can make sense because records may be much.
Binary Search Trees (BSTs) 18 February Binary Search Tree (BST) An important special kind of binary tree is the BST Each node stores some information.
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.
Indexing Database Management Systems. Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B + -Tree Index Files File Organization 2.
Temporal Indexing MVBT. Temporal Indexing Transaction time databases : update the last version, query all versions Queries: “Find all employees that worked.
1 Binary Search Trees   . 2 Ordered Dictionaries Keys are assumed to come from a total order. New operations: closestKeyBefore(k) closestElemBefore(k)
CHAPTER 51 LINKED LISTS. Introduction link list is a linear array collection of data elements called nodes, where the linear order is given by means of.
LINKED LISTS.
Azita Keshmiri CS 157B Ch 12 indexing and hashing
Indexing ? Why ? Need to locate the actual records on disk without having to read the entire table into memory.
Persistent Data Structures (Version Control)
Extra: B+ Trees CS1: Java Programming Colorado State University
Temporal Indexing MVBT.
Lecture 22 Binary Search Trees Chapter 10 of textbook
CSCI 104 Log Structured Merge Trees
Red-Black Trees Motivations
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
CMSC 341 Lecture 10 B-Trees Based on slides from Dr. Katherine Gibson.
B-Trees (continued) Analysis of worst-case and average number of disk accesses for an insert. Delete and analysis. Structure for B-tree node.
Multi-Way Search Trees
Balanced-Trees This presentation shows you the potential problem of unbalanced tree and show two way to fix it This lecture introduces heaps, which are.
B-Trees CSE 373 Data Structures CSE AU B-Trees.
Balanced-Trees This presentation shows you the potential problem of unbalanced tree and show two way to fix it This lecture introduces heaps, which are.
B-Trees CSE 373 Data Structures CSE AU B-Trees.
Advanced Implementation of Tables
CSE 373, Copyright S. Tanimoto, 2002 B-Trees -
Red Black Trees (Guibas Sedgewick 78)
CSE 326: Data Structures Lecture #9 AVL II
B-Trees CSE 373 Data Structures CSE AU B-Trees.
Binary Search Trees < > = Dictionaries
Presentation transcript:

Planar point location -- example

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).

What are we after ? Break each operation into elementary access steps (ptr traversal) and update steps (assignments, allocations). Want a persistent simulation with consumes O(1) time per update or access step, and O(1) space per update step.

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. The space penalty of the transformation would be O(1) per update step. In particular, this would give us an O(n) space solution to the planar point location problem

The fat node method Every pointer field can store many values, each tagged with a version number. NULL 4 5 7 15

The fat node method (Cont.) Simulation of an update step when producing version i: NULL 4 5 When a new node is created by the ephemeral update we create a new node, each value of a field in the new node is marked with version i. 7 15 When we change a value of a field f to v, we add an entry to the list of f with key i and value v

The fat node method (Cont.) Simulation of an access step when navigating in version i: NULL 4 5 The relevant value is the one tagged with the largest version number smaller than i 7 15

Partialy persistent deques via the fat node method 1 x 1 V1 Null Null V2 = inject(y,V1) x Null 2 1 y Null V3 = eject(V2) x 2 1 y 3 z V4= inject(z,V3) x Null 2 1 y 3 4

Fat node -- analysis Space is ok -- O(1) per update step That would give O(n) space for planar point location since each insertion/deletion does O(1) changes amortized. We screwed up the update time, it may take O(log m) to traverse a pointer, where m is the # of versions So query time goes up to O(log2n) and preprocessing time is O(nlog2n)

Node copying This is a general method to make pointer based data structures partially persistent. Nodes have to have bounded in degree and bounded outdegree We will show this method first for balanced search trees which is a slightly simpler case than the general case. Idea: It is similar to the fat node method just that we won’t make nodes too fat.

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 ptr at the parent is occupied copy the parent and continue going up this way.

Insert into persistent 2-4 trees with node copying . . . . . . . . . . . . . . . . . 1 3 12 14 18 20 21 28 16

Insert into persistent 2-4 trees with node copying 1 . . . . . . . . . . . . . . . . . 1 3 12 14 18 20 21 28 12 14 16 18

Insert into persistent 2-4 trees with node copying 1 . . . . . . . . . . . . . . . . . 1 3 12 14 18 20 21 28 29 12 14 16 18

Insert into persistent 2-4 trees with node copying 1 . . . . . . . . . . . . . . . . . 1 3 12 14 18 20 21 28 12 14 16 18 20 21 28 29

Insert into persistent 2-4 trees with node copying 1 . . . . . . . . . . . . . . . . . 1 3 12 14 18 20 21 28 12 14 16 18 20 21 28 29

Node copying -- analysis The time slowdown per access step is O(1) since there is only a constant # of extra pointers per node. What about the space blowup ? O(1) (amortized) new nodes per update step due to nodes that would have been created by the ephemeral implementation as well. How about nodes that are created due to node copying when the extra pointer is full ?

Node copying -- analysis We’ll show that only O(1) of copings occur on the average per update step. Amorized space consumption = real space consumption +   = #(used slots in live nodes) A node is live if it is reachable from the root of the most recent version. ==> Amortized space cost of node copying is 0.

Node copying in general Each persistent nodes has d + p + e + 1 pointers e = extra pointers p = predecessor pointers 1 = copy pointer. 4 7 11 6 5 live

Node copying in general (cont) When there is no free extra ptr copy the node. When you copy node x, and x points to y, c(x) should point to y or to c(y) if y has been copied, update the corresponding predecessor ptr in y or c(y). Add x to the set S of copied nodes. (S contains 1 node initially) y 7 11 x 7

Node copying in general (cont) When there is no free extra ptr copy the node. When you copy node x, and x points to y, c(x) should point to y or to c(y) if y has been copied, update the corresponding predecessor ptr in y or c(y). Add x to the set S of copied nodes. (S contains 1 node initially) 11 y 7 11 x 7

Node copying in general (cont) In the general step it could be that when we copy x, y has already been copied 11 y 7 11 x 7

Node copying in general (cont) Remove any node x from S, for each node y indicated by a predecessor pointer in x find in y the live pointer to x. If this ptr has version stamp i, replace it by a ptr to c(x). If this ptr has version stamp less than i, add to y a ptr to c(x) with version stamp i. If there is no room, copy y as before, and add it to S.

Node copying (analysis) Actual space consumed is |S|  = #(used extra fields in live nodes)  = -e|S| + p|S| This is smaller than |S| if e > p (Actually e ≥ p suffices if we were more careful) So whether there were any copings or not the amortized space cost of a single update step is O(1)

The fat node method - full persistence Does it also work for full persistence ? NULL 1 5 5 6 7 6 We have a navigation problem.

The fat node method - full persistence (cont) Maintain a total order of the version tree. 5 6 7 8 9 5 6 7 8 5 6 7 8 9

The fat node method - full persistence (cont) When a new version is created add it to the list immediately after its parent. ==> The list is a preorder of the version tree.

The fat node method - full persistence (cont) When traversing a field in version i, the relevant value is the one recorded with a version preceding i in the list and closest to it. 5 6 7 8 NULL 1 9 5 6 5 6 7 8 5 6 7 8 9

The fat node method - full persistence (cont) How do we update ? 5 6 7 8 10 5 6 7 8 9 NULL 1 9 5 7 6 5 6 7 8 9

The fat node method - full persistence (cont) 5 6 7 8 NULL 1 10 5 9 7 6 10 5 6 7 8 9 5 10 7 9 6 8 So what is the algorithm in general ?

The fat node method - full persistence (cont) Suppose that when we create version i we change field f to have value v. Let i1 (i2) be the first version to the left (right) of i that has a value recorded at field f i1 f i i2 v i1 i i2

The fat node method - full persistence (cont) We add the pair (i,v) to the list of f Let i+ be the version following i in the version list v’ i1 i+ f i i2 v i1 i i+ i2 If (i+ < i2) or i+ exists and i2 does not exist add the pair (i+,v’) where v’ is the value associated with i1.

Fully persistent 2-4 trees with the fat node method . . . . . . . . . . . . . . . . . 1 3 12 14 18 20 21 28 16

Insert into fully persistent 2-4 trees (fat nodes) 1 1 1 . . . . . . . . . . . . . . . . . 1 3 12 14 18 20 21 28 12 14 16 18

Insert into fully persistent 2-4 trees (fat nodes) 2 1 1 2 1 . . . . . . . . . . . . . . . . . 1 3 12 14 18 20 21 28 29 12 14 16 18

Insert into persistent 2-4 trees with node copying 2 1 1 2 2 1 . . . . . . . . . . . . . . . . . 1 3 12 14 18 20 21 28 12 14 16 18 20 21 28 29

Insert into persistent 2-4 trees with node copying 2 1 1 2 2 1 1 . . . . . . . . . . . . . . . . . 1 3 12 14 18 20 21 28 12 14 16 18 20 21 28 29

Fat node method (cont) How do we efficiently find the right value of a field in version i ? Store the values sorted by the order determined by the version list. Use a search tree to represent this sorted list. To carry out a find on such a search tree we need in each node to answer an order query on the version list. Use Dietz and Sleator’s data structure for the version list.

Fat node method (summary) We can find the value to traverse in O(log(m)) where m is the number of versions We get O(1) space increase per ephemeral update step O(log m) time slowdown per ephemeral access step

Node splitting Similar to node copying. (slightly more evolved) Allows to avoid the O(log m) time slowdown. Converts any pointer based data structure with constant indegrees and outdegrees to a fully persistent one. The time slowdown per access step is O(1) (amortized). The space blowup per update step is O(1) (amortized)

Search trees via node splitting You get fully persistent search trees in which each operation takes O(log n) amortized time and space. Why is the space O(log n) ? Since in the ephemeral settings the space consumption is O(1) only amortized.

Search trees via node splitting So what do we need in order to get persistent search trees with O(1) space cost per update (amortized) ? We need an ephemeral structure in which the space consumption per update is O(1) on the worst case. You can do it ! ==> Red-black trees with lazy recoloring

What about deques ? We can apply node splitting to get fully persistent deques with O(1) time per operation. We can also transform the simulation by stacks into a real time simulation and get O(1) time solution. What if we want to add the operation concatenate ? None of the methods seems to extend...