Predecessor. Predecessor. Predecessors. Predecessors. Predecessor Problem van Emde Boas Tries. Predecessor Problem van Emde Boas Tries.

Similar documents
Predecessor. Predecessor Problem van Emde Boas Tries. Philip Bille

Predecessor Data Structures. Philip Bille

x-fast and y-fast Tries

x-fast and y-fast Tries

Outline for Today. How can we speed up operations that work on integer data? A simple data structure for ordered dictionaries.

Outline for Today. How can we speed up operations that work on integer data? A simple data structure for ordered dictionaries.

Lecture 12 March 21, 2007

Range Reporting. Range reporting problem 1D range reporting Range trees 2D range reporting Range trees Predecessor in nested sets kd trees

Lecture 9 March 4, 2010

Lecture 3: Cuckoo Hashing (ctd.) Predecessor Data Structures. Johannes Fischer

Binary Search Trees. Nearest Neighbor Binary Search Trees Insertion Predecessor and Successor Deletion Algorithms on Trees.

Binary Search Trees. Binary Search Trees. Nearest Neighbor. Nearest Neighbor

(2,4) Trees. 2/22/2006 (2,4) Trees 1

On Dynamic Range Reporting in One Dimension

COMP Analysis of Algorithms & Data Structures

Range Reporting. Range Reporting. Range Reporting Problem. Applications

Searching: Introduction

TREES. Trees - Introduction

Data Structures and Algorithms

B-Trees. Version of October 2, B-Trees Version of October 2, / 22

van Emde Boas trees. Dynamic algorithms F04.Q4, March 29, 2004

(2,4) Trees Goodrich, Tamassia (2,4) Trees 1

Integer Algorithms and Data Structures

Augmenting Data Structures

Lecture 6: Analysis of Algorithms (CS )

An AVL tree with N nodes is an excellent data. The Big-Oh analysis shows that most operations finish within O(log N) time

(2,4) Trees Goodrich, Tamassia. (2,4) Trees 1

Lecture: Analysis of Algorithms (CS )

Geometric Data Structures

Cache-Oblivious String Dictionaries

Friday Four Square! 4:15PM, Outside Gates

Dynamic Algorithms Multiple Choice Test

Searching a Sorted Set of Strings

DDS Dynamic Search Trees

Fusion Trees Part Two

Algorithms for Memory Hierarchies Lecture 2

CS350: Data Structures B-Trees

Physical Level of Databases: B+-Trees

Search Trees - 1 Venkatanatha Sarma Y

CSE 638: Advanced Algorithms. Lectures 18 & 19 ( Cache-efficient Searching and Sorting )

CS 315 Data Structures Spring 2012 Final examination Total Points: 80

Lec 17 April 8. Topics: binary Trees expression trees. (Chapter 5 of text)

Material You Need to Know

Data Structure. A way to store and organize data in order to support efficient insertions, queries, searches, updates, and deletions.

Unit 6 Chapter 15 EXAMPLES OF COMPLEXITY CALCULATION

Topics Applications Most Common Methods Serial Search Binary Search Search by Hashing (next lecture) Run-Time Analysis Average-time analysis Time anal

Motivation for B-Trees

Quickheaps. 2nd Workshop on Compression, Text and Algorithms 2007

Data Compression Techniques

Lecture L16 April 19, 2012

CS 350 : Data Structures B-Trees

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

1. Meshes. D7013E Lecture 14

CS F-11 B-Trees 1

Binary Trees, Binary Search Trees

Multi-way Search Trees. (Multi-way Search Trees) Data Structures and Programming Spring / 25

CS127: B-Trees. B-Trees

Lecture 11: Multiway and (2,4) Trees. Courtesy to Goodrich, Tamassia and Olga Veksler

Balanced Trees Part One

Computational Geometry

Chapter 11: Indexing and Hashing

Persistent Data Structures (Version Control)

Algorithms and Data Structures: Efficient and Cache-Oblivious

Chapter 12: Indexing and Hashing. Basic Concepts

MITOCW watch?v=ninwepprkdq

Lecture 3: B-Trees. October Lecture 3: B-Trees

Lecture 13 Thursday, March 18, 2010

Chapter 12: Indexing and Hashing (Cnt(

Chapter 12: Indexing and Hashing

Chapter 12: Indexing and Hashing

Balanced Search Trees

CS301 - Data Structures Glossary By

Design and Analysis of Algorithms Lecture- 9: B- Trees

Fast Evaluation of Union-Intersection Expressions

Analysis of Algorithms

Dynamic Routing Tables Using Simple Balanced. Search Trees

A set of nodes (or vertices) with a single starting point

Module 3: Hashing Lecture 9: Static and Dynamic Hashing. The Lecture Contains: Static hashing. Hashing. Dynamic hashing. Extendible hashing.

DIT960 Datastrukturer

Chapter 12 Digital Search Structures

Data structures. Organize your data to support various queries using little time and/or space

Bioinformatics Programming. EE, NCKU Tien-Hao Chang (Darby Chang)

Binary Trees. Recursive definition. Is this a binary tree?

58093 String Processing Algorithms. Lectures, Autumn 2013, period II

Multiway Range Trees: Scalable IP Lookup with Fast Updates

9/29/2016. Chapter 4 Trees. Introduction. Terminology. Terminology. Terminology. Terminology

1 Probability Review. CS 124 Section #8 Hashing, Skip Lists 3/20/17. Expectation (weighted average): the expectation of a random quantity X is:

: Parallel Algorithms Exercises, Batch 1. Exercise Day, Tuesday 18.11, 10:00. Hand-in before or at Exercise Day

W4231: Analysis of Algorithms

Faster Cover Trees. Mike Izbicki and Christian R. Shelton UC Riverside. Izbicki and Shelton (UC Riverside) Faster Cover Trees July 7, / 21

Design and Analysis of Algorithms Lecture- 9: Binary Search Trees

UNIT III BALANCED SEARCH TREES AND INDEXING

CSIT5300: Advanced Database Systems

Binary search trees (BST) Binary search trees (BST)

Trees. Q: Why study trees? A: Many advance ADTs are implemented using tree-based data structures.

COMP3121/3821/9101/ s1 Assignment 1

Introduction to Indexing 2. Acknowledgements: Eamonn Keogh and Chotirat Ann Ratanamahatana

Computing intersections in a set of line segments: the Bentley-Ottmann algorithm

Extra: B+ Trees. Motivations. Differences between BST and B+ 10/27/2017. CS1: Java Programming Colorado State University

A Secondary storage Algorithms and Data Structures Supplementary Questions and Exercises

Transcription:

Philip Bille s problem. Maintain a set S U = {,..., u-} supporting predecessor(x): return the largest element in S that is x. sucessor(x): return the smallest element in S that is x. insert(x): set S = S {x} delete(x): set S = S - {x} s Applications. Simplest version of nearest neighbor problem. Several applications in other algorithms and data structures. Probably most practically solved problem in the world: Out all computational resources globally a huge fraction is used to solve the predecessor problem! u- predecessor(x) x successor(x)

s Routing IP-Packets Where should we forward the packet to? To address matching the longest prefix of 92..44.23. Equivalent to predecessor problem. Best practical solutions based on advanced predecessor data structures [Degermark, Brodnik, Carlsson, Pink 997] s Which solutions do we know? Linked list Balanced binary search trees. Bitvectors 92..42.255 92..44.23? 92..44.2 92.5.. van Emde Boas Goal. Static predecessor with O(log log u) query time. Solution in 5 steps. Bitvector. Very slow Two-level bitvector. Slow.. [Boas 975]. Fast.

Solution : Bitvector Solution 2: Two-Level Bitvector u /2 Data structure. Bitvector. (x): Walk left. Time. O(u) u- u /2 u /2 u /2 u /2 Data structure. Top bitvector + u /2 bottom bitvectors. (x): Walk left in bottom + walk left in top + walk left bottom. Time. O(u /2 + u /2 + u /2 ) = O(u /2 ) To find indices in top and bottom write x = hi(x) u /2 + lo(w) Index in top is hi(x) and index in bottom is lo(x). Solution 3: Two-Level Bitvector with less Walking Solution 4: Two-Level Bitvector within Top and Bottom u /2 u /2 u /2 u /2 u /2 Data structure. Solution 2 with min and max for each bottom structure. Data structure. Apply solution 3 to top and bottom structures of solution 3. (x): If hi(x) in top and lo(x) min in bottom[lo(x)] walk left in bottom. if hi(x) in top and lo(x) < min or hi(x) not in top walk left in top. Return max at first non-empty position in top. We either walk in bottom or top. Time. O(u /2 ) Observation. Query is walking left in one vector of size u /2 + O() extra work. Why not walk using a predecessor data structure? Walking left in vector of size u /2 now takes O((u /2 ) /2 ) = O(u /4 ) time. Each level adds O() extra work. Time. O(u /4 ) Why not do this recursively?

Solution 5: van Emde Boas van Emde Boas O(n) space. O(log log u) time. Can also be made dynamic. Data structure. Apply recursively until size of vectors is constant. Time. T(u) = T(u /2 ) + O() = O(log log u) Space. O(u) Combined with perfect hashing we can reduce it to O(n) [Mehlhorn and Näher 99]. Tries Goal. Static predecessor with O(n) space and O(log log u) query time. Equivalent to van Emde Boas but different perspective. Simpler? Solution in 3 steps. Trie. Slow and too much space. X-fast trie. Fast but too much space. Y-fast trie. Fast and little space.

Tries Solution : Top-down Traversal 2 3 4 5 6 7 8 9 2 3 4 5 S = {, 2, 8,, 4} = {2, 2, 2, 2, 2} Trie. Tree T of prefixes of binary representation of keys in S. Depth of T is log u Number of nodes in T is O(n log u). Data structure. T as binary tree with min and max for each node + keys ordered in a linked list. (x): Top-down traversal to find the longest common prefix of x with T. x branches of T to right (x) is max of sibling branch. x branches of T to left Successor(x) is min of sibling branch. Use linked list to get predecessor(x). Time. O(log u) Space. O(n log u) 2 3 4 5 6 7 8 9 2 3 4 5 S = {, 2, 8,, 4} = {2, 2, 2, 2, 2} Solution 2: X-Fast Trie Solution 2: X-Fast Trie 2 3 4 5 6 7 8 9 2 3 4 5 S = {, 2, 8,, 4} = {2, 2, 2, 2, 2} Data structure. For each level store a dictionary of prefixes of keys + solution. Example. d = {,}, d2 = {,, }, d3 = {,,,, }, d4 = S Space. O(n log u) 2 3 4 5 6 7 8 9 2 3 4 5 S = {, 2, 8,, 4} = {2, 2, 2, 2, 2} (x): Binary search over levels to find longest matching prefix with x. Example. ( 9 = 2 ): 2 in d2 exists continue in bottom /2 of tree. 2 in d3 exists continue in bottom /4 of tree. 2 in d4 does not exist 2 is longest prefix. Time. O(log log u)

Solution 2: X-Fast Trie Solution 3: Y-Fast Trie x-fast trie BBSTs 2 3 4 5 6 7 8 9 2 3 4 5 S = {, 2, 8,, 4} = {2, 2, 2, 2, 2} O(log log u) time O(n log u) space. How do we get linear space? u- Bucketing. Partition S into O(n / log u) groups of log u consecutive keys. Compute S = set of split keys between groups. S = O(n/log u) Data structure. x-fast trie over S + balanced binary search trees for each group. Space. x-fast trie: O( S log u) = O(n/ log u log u) = O(n). Balanced binary search trees: O(n). O(n) in total. Solution 3: Y-Fast Trie Solution 3: Y-Fast Trie x-fast trie BBSTs u- (x): Compute s = predecessor(x) in x-fast trie. Compute predecessor(x) in BBST to the left or right of s. Time. x-fast trie: O(log log u) balanced binary search tree: O(log (group size)) = O(log log u). O(log log u) in total. 2 3 4 5 6 7 8 9 2 3 4 5 S = {, 2, 8,, 4} = {2, 2, 2, 2, 2} O(log log u) time O(n) space.

Y-Fast Tries O(n) space. O(log log u) time. What about updates? Theorem. We can solve the dynamic predecessor problem in O(n) space O(log log u) expected time for predecessor and updates. From dynamic hashing