List Order Maintenance

Slides:



Advertisements
Similar presentations
List Order Maintenance
Advertisements

Priority Queues  MakeQueuecreate new empty queue  Insert(Q,k,p)insert key k with priority p  Delete(Q,k)delete key k (given a pointer)  DeleteMin(Q)delete.
Comp 122, Spring 2004 Binary Search Trees. btrees - 2 Comp 122, Spring 2004 Binary Trees  Recursive definition 1.An empty tree is a binary tree 2.A node.
Advanced Data Structures NTUA Spring 2007 B+-trees and External memory Hashing.
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.
Time O(log d) Exponential-search(13) Finger Search Searching in a sorted array time O(log n) Binary-search(13)
B+-Trees (PART 1) What is a B+ tree? Why B+ trees? Searching a B+ tree
1 Self-Adjusting Data Structures. 2 Lists [D.D. Sleator, R.E. Tarjan, Amortized Efficiency of List Update Rules, Proc. 16 th Annual ACM Symposium on Theory.
Unified Access Bound 1 [M. B ă doiu, R. Cole, E.D. Demaine, J. Iacono, A unified access bound on comparison- based dynamic dictionaries, Theoretical Computer.
Multiversion Access Methods - Temporal Indexing. Basics A data structure is called : Ephemeral: updates create a new version and the old version cannot.
O(log n) bits or atomic elements
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.
B+-tree and Hashing.
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
Fully Persistent B-Trees 23 rd Annual ACM-SIAM Symposium on Discrete Algorithms, Kyoto, Japan, January 18, 2012 Gerth Stølting Brodal Konstantinos Tsakalidis.
Cache Oblivious Search Trees via Binary Trees of Small Height
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 )
B-Trees Chapter 9. Limitations of binary search Though faster than sequential search, binary search still requires an unacceptable number of accesses.
B-Trees (continued) Analysis of worst-case and average number of disk accesses for an insert. Delete and analysis. Structure for B-tree node.
Time O(log d) Exponential-search(13) Finger Search Searching in a sorted array time O(log n) Binary-search(13)
Λίστα Εργασιών Data Structures for Tree Manipulation D. Harel and R.E. Tarjan. Fast Algorithms for finding nearest common ancestors. SIAM J. Computing,
1 Biased 2-b trees (Bent, Sleator, Tarjan 1980). 2 Goal Keep sorted lists subject to the following operations: find(x,L) insert(x,L) delete(x,L) catenate(L1,L2)
1 The Online Labeling Problem Jan Bulánek (Institute of Math, Prague) Martin Babka (Charles University) Vladimír Čunát (Charles University) Michal Koucký.
1 The Online Labeling Problem Jan Bulánek (Institute of Math, Prague) Martin Babka (Charles University) Vladimír Čunát (Charles University) Michal Koucký.
Lecture 9COMPSCI.220.FS.T Lower Bound for Sorting Complexity Each algorithm that sorts by comparing only pairs of elements must use at least 
Dynamic Dictionaries Primary Operations:  get(key) => search  put(key, element) => insert  remove(key) => delete Additional operations:  ascend()
Lower Bounds & Sorting in Linear Time
arxiv.org/abs/ y 3-sided x1 x2 x1 x2 top-k
Binary Search Trees What is a binary search tree?
CSC317 Selection problem q p r Randomized‐Select(A,p,r,i)
Self-Adjusting Data Structures
Andreas Klappenecker [partially based on the slides of Prof. Welch]
CSCE 3110 Data Structures & Algorithm Analysis
CSCE 3110 Data Structures & Algorithm Analysis
lsb(x) = Least Significant Bit ?
Tree-based Indexing Hessam Zakerzadeh.
Multiway Search Trees Data may not fit into main memory
COP Introduction to Database Structures
Indexing ? Why ? Need to locate the actual records on disk without having to read the entire table into memory.
Persistent Data Structures (Version Control)
Chapter 6 Transform-and-Conquer
Multiway search trees and the (2,4)-tree
Binary Search Tree Chapter 10.
Searching in Trees Gerth Stølting Brodal Aarhus University
Hashing Exercises.
Interval Heaps Complete binary tree.
Fast Trie Data Structures
B-Trees (continued) Analysis of worst-case and average number of disk accesses for an insert. Delete and analysis. Structure for B-tree node.
Lower Bound Theory.
Search Sorted Array: Binary Search Linked List: Linear Search
B+-Trees and Static Hashing
Order maintenance problem
STACS arxiv.org/abs/ y 3-sided x1 x2 x1 x2 top-k
ITEC 2620M Introduction to Data Structures
Presented By Gregory Giguashvili
Strict Fibonacci Heaps
Lecture 21: B-Trees Monday, Nov. 19, 2001.
CS6045: Advanced Algorithms
Lower Bounds & Sorting in Linear Time
Advanced Implementation of Tables
Database Design and Programming
8th Workshop on Massive Data Algorithms, August 23, 2016
Range Queries on Uncertain Data
B+-Trees j a0 k1 a1 k2 a2 … kj aj j = number of keys in node.
Priority Queues Supports the following operations. Insert element x.
Search Sorted Array: Binary Search Linked List: Linear Search
Discrete Range Maximum
Order maintenance problem
Sorting We have actually seen already two efficient ways to sort:
CS210- Lecture 20 July 19, 2005 Agenda Multiway Search Trees 2-4 Trees
Presentation transcript:

List Order Maintenance B H D I C F G A Insert(D,I) Build data structure Insert(x,y) Insert y after x Order(x,y) Returns if x is to the left of y Monotonic List Labeling 10 12 14 17 18 19 20 21 24 x y Each node an integer label Relabel nodes on insertion Insert(x,y) Insert y after x Density Maintenance 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 A J C G D B F H E File gap O(1) Insert(i,x) Insert x at postion i Shift elements on insertion

List Order Maintenance [P. Dietz, D. Sleator, Two algorithms for maintaining order in a list, ACM Conference on Theory of Computing, 365-372, 1987] [A. Tsakalidis, Maintaining Order in a Generalized Linked List. Acta Informatica 21: 101-112, 1984] Query and Insert O(1) Monotonic List Labeling [P. Dietz, Maintaining Order in a Linked List, ACM Conference on Theory of Computing, 122-127, 1982] [P. Dietz, J. Seiferas, J. Zhang: A Tight Lower Bound for On-line Monotonic List Labeling. Scandinavian Workshop on Algorithm Theory, 131-142, 1994] Max label O(nk), k>1+ε (log n) relabelings [D. Willard, Maintaining Dense Sequential Files in a Dynamic Environment, ACM Conference on Theory of Computing, 114-121, 1982] [P. Dietz, J. Zhang: Lower Bounds for Monotonic List Labeling. Scandinavian Workshop on Algorithm Theory, 173-180, 1990] ICALP 2013: Jan Bulánek, Michal Koucký, Michael Saks “On Randomized Online Labeling with Polynomially Many Labels” prove lower bound also holds for randomized algorithms with O(n^k) labels. ESA 2012: Martin Babka, Jan Bulánek, Vladimír Čunát, Michal Koucký, Michael Saks “On Online Labeling with Polynomially Many Labels” alternative (corrected?) lower bound proof for O(n^k) labels. STOC 2012: Jan Bulánek, Michal Koucký, Michael Saks “Tight lower bounds for the online labeling problem” proove that O(log(n)3) is optimal for the special case where array size has n, and n insertions are performed Max label O(n) (log2 n) relabelings Applications [G. Brodal, R. Fagerberg, R. Jacob, Cache-Oblivious Search Trees via Binary Trees of Small Height, ACM-SIAM Symposium on Discrete Algorithms, pages 39-48, 2002] [J. Driscoll, N. Sarnak, D. Sleator, R. Tarjan, Making Data Structures Persistent, Journal of Computer and System Sciences, 38(1), 86-124, 1989]

Amortized O(log2 n) Density Maintenance Threshold  = 1/(2log n) Level i node overflows if density > 1-i∙ Insert redistribute lowest non-overflowing ancestor  a child requires  fraction insertions before next overflow  amoritzed insertion cost = #levels ∙ 1 /  = O(log2 n) redistribution threshold level redistribute 4 4/8 density 5/8 3 5/8 4/4 2 6/8 3/2 1 7/8 2/1 1 Insert(6,K) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 A J C G D B F H E before after A J K C G D B F H E

 List Order Maintenance Max label O(n) Amortized O(log2 n) Density Maintenance Threshold  = 1/(2log n) Level i node overflows if density > 1-i∙ Insert redistribute lowest non-overflowing ancestor  a child requires  fraction insertions before next overflow  amoritzed insertion cost = #levels ∙ 1 /  = O(log2 n)  List Order Maintenance Max label O(n) Amortized O(log2 n) relabelings / insertion redistribution threshold level redistribute 4 4/8 density 5/8 3 5/8 4/4 2 6/8 3/2 1 7/8 2/1 1 Insert(6,K) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 A J C G D B F H E before after A J K C G D B F H E

Amortized O(log n) List Relabelings Level i node overflows if density > (2/3)i Insert redistribute lowest non-overflowing ancestor  ≤ log4/3 n levels  max label 2log4/3 n ≤ n2.41  a child requires 1/2 fraction insertions before next overflow  amortized insertion cost = #levels ∙ 3 = O(log n) 2/3  1/2 +  implies max label O(n1/log(1+2)) redistribution threshold level redistribute density 3/16 4 16/81 3/8 3 8/27 2/4 2 4/9 2/2 1 2/3 2/1 1 Insert(C,K) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 A C before after A C K

Amortized O(log n) List Relabelings [P. Dietz, D. Sleator, Two algorithms for maintaining order in a list, ACM Conference on Theory of Computing, 365-372, 1987] 1 2 4 5 7 8 9 12 15 17 18 19 21 23 i wi = 12 - 8 2i w2i = 18 - 8 i = 1 while w2i ≤ 4 ∙ wi do i = i +1 Relabel uniformly ”2i area” Insertion: average label of neighbors, otherwise relabel Proof for amortized complexity: 1 full page Only relabels to the right Max label M=4n2 Requires labels mod M+1

Monotonic List Labeling O(log N) easy insertions N 32 48 56 60 64 128 192 256 x y Insert(x,y) Label y = (left + right)/2  Can perform log N insertions without relabeling

Amortized O(1) List Order Maintenance top-tree of size ≤ n/log2 n Amortized O(log2 n) Density Maintenance 1 2 4 5 7 8 9 11 12 15 17 18 19 21 23 ... 12 16 7 13 the list 8 16 4 12 5 15 2 14 two-level bucket of degree [log n..2log n] and keys [0..n2] Alternative: Amortized O(log n) top with n^O(1) labels, and only buckets of size O(log n) Insertion create and label new leaf split nodes of degree > 2log n and relabel with gap n insert in top tree

Amortized O(1) List Order Maintenance Worst-case Worst-case [Willard 1982] top-tree of size ≤ n/log2 n Amortized O(log2 n) Density Maintenance 1 2 4 5 7 8 9 11 12 15 17 18 19 21 23 ... 12 16 7 13 the list three 8 16 4 12 5 15 2 14 two-level bucket of degree [log n..2log n] and keys [0..n2] Insertion create and label new leaf split nodes of degree > 2log n and relabel with gap n insert in top tree + incremental insertion into top tree + incremental splitting of bucket nodes + every O(log2 n)’th operation split largest bucket largest bucket size O(log3 n)

a9 a5 a12 a11 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 ... xn