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.

Slides:



Advertisements
Similar presentations
Uniform algorithms for deterministic construction of efficient dictionaries Milan Ružić IT University of Copenhagen Faculty of Mathematics University of.
Advertisements

Gerth Stølting Brodal University of Aarhus Monday June 9, 2008, IT University of Copenhagen, Denmark International PhD School in Algorithms for Advanced.
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.
Sorting Comparison-based algorithm review –You should know most of the algorithms –We will concentrate on their analyses –Special emphasis: Heapsort Lower.
Advanced Data Structures NTUA Spring 2007 B+-trees and External memory Hashing.
Fusion Trees Advanced Data Structures Aris Tentes.
1 Hashing, randomness and dictionaries Rasmus Pagh PhD defense October 11, 2002.
Hierarchy-conscious Data Structures for String Analysis Carlo Fantozzi PhD Student (XVI ciclo) Bioinformatics Course - June 25, 2002.
1 Nearest Commen Ancestors (NCA) Discrete Range Maximum Cartesian Tree [Vuillemin 1980] i j max(i, j) i.
Dynamic Planar Range Maxima Queries (presented at ICALP 2011) Gerth Stølting Brodal Aarhus University Kostas Tsakalidis LIAFA, Université Paris Diderot,
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.
Engineering a Sorted List Data Structure for 32 Bit Keys Roman Dementiev Lutz Kettner Jens Mehnert Peter Sanders MPI für Informatik, Saarbrücken.
B+-tree and Hashing.
Cache-Oblivious B-Trees
DAST, Spring © L. Joskowicz 1 Data Structures – LECTURE 1 Introduction Motivation: algorithms and abstract data types Easy problems, hard problems.
Rank-Pairing Heaps Bernhard Haeupler, Siddhartha Sen, and Robert Tarjan, ESA
Course Review COMP171 Spring Hashing / Slide 2 Elementary Data Structures * Linked lists n Types: singular, doubly, circular n Operations: insert,
Comparison Based Dictionaries: Fault Tolerance versus I/O Efficiency Gerth Stølting Brodal Allan Grønlund Jørgensen Thomas Mølhave University of Aarhus.
Unit 11a 1 Unit 11: Data Structures & Complexity H We discuss in this unit Graphs and trees Binary search trees Hashing functions Recursive sorting: quicksort,
COMP 171 Data Structures and Algorithms Tutorial 10 Hash Tables.
Cache Oblivious Search Trees via Binary Trees of Small Height
Data Structures, Spring 2004 © L. Joskowicz 1 DAST – Final Lecture Summary and overview What we have learned. Why it is important. What next.
Melding Priority Queues Ran Mendelson Robert E. Tarjan Mikkel Thorup Uri Zwick SWAT 2004.
DAST, Spring © L. Joskowicz 1 Data Structures – LECTURE 1 Introduction Motivation: algorithms and abstract data types Easy problems, hard problems.
Data Structures Hashing Uri Zwick January 2014.
© Neeraj Suri EU-NSF ICT March 2006 Dependable Embedded Systems & SW Group Prof. Neeraj Suri Dan Dobre Overview: 1.Merge.
Sorting in Linear Time Lower bound for comparison-based sorting
1 Hash Tables  a hash table is an array of size Tsize  has index positions 0.. Tsize-1  two types of hash tables  open hash table  array element type.
Final Review Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
B-trees and kd-trees Piotr Indyk (slides partially by Lars Arge from Duke U)
Time O(log d) Exponential-search(13) Finger Search Searching in a sorted array time O(log n) Binary-search(13)
Wolfgang Mulzer Institut f ür Informatik Data Structures on Event Graphs Bernard ChazelleWolfgang Mulzer FU Berlin Princeton University.
Outline Priority Queues Binary Heaps Randomized Mergeable Heaps.
Bucket & Radix Sorts. Efficient Sorts QuickSort : O(nlogn) – O(n 2 ) MergeSort : O(nlogn) Coincidence?
A Worst Case, Constant Time Priority Queue: Beating a Lower Bound Ian Munro University of Waterloo Joint work with Andrej Brodnik (Ljubljana & Luleå) Svante.
Λίστα Εργασιών Data Structures for Tree Manipulation D. Harel and R.E. Tarjan. Fast Algorithms for finding nearest common ancestors. SIAM J. Computing,
Searching and Sorting Recursion, Merge-sort, Divide & Conquer, Bucket sort, Radix sort Lecture 5.
Java Methods Big-O Analysis of Algorithms Object-Oriented Programming
Dynamic Perfect Hashing By: Tomer Shlomi Dynamic Perfect Hashing: Upper and Lower Bounds – Martin Dietzfelbinger, Anna Karlin, Kurt Mehlhorn, Friedhelm.
Data Structure II So Pak Yeung Outline Review  Array  Sorted Array  Linked List Binary Search Tree Heap Hash Table.
Hashing 1 Hashing. Hashing 2 Hashing … * Again, a (dynamic) set of elements in which we do ‘search’, ‘insert’, and ‘delete’ n Linear ones: lists, stacks,
1 Nearest Common Ancestors (NCA) Discrete Range Maximum Cartesian Tree [Vuillemin 1980] i j max(i, j) i.
Equivalence Between Priority Queues and Sorting in External Memory
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()
Sorting Integers in the RAM Model Gerth Stølting Brodal Joint work with Djamal Belazzougui and Jesper Sindal Nielsen (to be presented at the 14th Scandinavian.
Internal Memory Pointer MachineRandom Access MachineStatic Setting Data resides in records (nodes) that can be accessed via pointers (links). The priority.
Memory Hierarchies [FLPR12] Matteo Frigo, Charles E. Leiserson, Harald Prokop, Sridhar Ramachandran. Cache- Oblivious Algorithms. ACM Transactions on Algorithms,
(A Survey on) Priority Queues IanFest, University of Waterloo, Waterloo, Ontario, Canada, August 14-15, 2013 Gerth Stølting Brodal Aarhus Universty.
Advanced Sorting 7 2  9 4   2   4   7
Chapter 11 Sorting Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++, Goodrich, Tamassia and Mount.
Self-Adjusting Data Structures
Data Structures: Disjoint Sets, Segment Trees, Fenwick Trees
lsb(x) = Least Significant Bit ?
A Worst Case, Constant Time Priority Queue
List Order Maintenance
Experimental evaluation of Navigation piles
Persistent Data Structures (Version Control)
Searching in Trees Gerth Stølting Brodal Aarhus University
Hashing Exercises.
Data Structures: Segment Trees, Fenwick Trees
Randomized Algorithms CS648
Searching CLRS, Sections 9.1 – 9.3.
Melding Priority Queues
Union-Find with Constant Time Deletions
Priority Queues Supports the following operations. Insert element x.
Discrete Range Maximum
Presentation transcript:

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 with fusion trees, Journal of Computer and System Sciences 47 (3): 424–436, 1993]

2 RAM model (Random Access Machine) Memory, infinite w bits - NOT shift-right XOR AND * + shift-left OR CPU, O(1) registers write read # reads Complexity = + # writes + # instructions performed not an AC 0 operation

3 Radix Sort n w bits [Cormen et al. 2009] w/log n x C OUNTING -S ORT = O(n∙w/log n) GOAL: Design algorithms with complexity independent of w (trans-dichotomous) [M.L. Fredman, D.E. Willard, Surpassing the information-theoretic bound with fusion trees, Journal of Computer and System Sciences 47 (3): 424–436, 1993]

4 [M. Thorup, On RAM Priority Queues. ACM-SIAM Symposium on Discrete Algorithms, 59-67, 1996] [Y. Han, M. Thorup, Integer Sorting in O(n  log log n) Expected Time and Linear Space, IEEE Foundations of Computer Science, , 2002] [A. Andersson, T. Hagerup, S. Nilsson, R. Raman: Sorting in linear time? ACM Symposium on Theory of Computing, , 1995] [D. Belazzougu, G. S. Brodal, J. A. S. Nielsen, Expected Linear Time Sorting for Word Size  (log 2 n  log log n), manuscript 2013] Sorting Comparison O(n∙log n) Radix-Sort O(n∙w/log n) [T96] O(n∙loglog n) [HT02] O(n∙  loglog n) exp. [AHNR95] O(n) exp., w ≥ log 2+  n [BBN13] O(n) exp., w ≥ log 2 n  loglog n Priority queues (Insert/DeleteMin) Comparison O(log n) [T96] O(loglog n) [HT02,T07] O(  loglog n) exp. [M. Thorup, On RAM Priority Queues. ACM-SIAM Symposium on Discrete Algorithms, 59-67, 1996] [Y. Han, M. Thorup, Integer Sorting in O(n  log log n) Expected Time and Linear Space, IEEE Foundations of Computer Science, , 2002] [Mikkel Thorup, Equivalence between priority queues and sorting, J. ACM 54(6), 2007]

5 [P. van Emde Boas, R. Kaas, and E. Zijlstra, Design and Implementation of an Efficient Priority Queue, Mathematical Systems Theory 10, , 1977] [P. Beame, F.E. Fich, Optimal Bounds for the Predecessor Problem and Related Problems. J. Comput. Syst. Sci. 65(1): 38-72, 2002] [M. Patrascu, M. Thorup, Time-space trade-offs for predecessor search, ACM Symposium on Theory of Computing, , 2006] [vKZ77] O(log w) [BF02] O(log w/loglog w) (static, space n O(1) ) O(log w/loglog w∙loglog n) (dynamic) Dynamic predecessor searching (w independent) Comparison O(log n) [FW93] O(log n/loglog n) [AT07] O(  log n/loglog n) [M.L. Fredman, D.E. Willard, Surpassing the information-theoretic bound with fusion trees, Journal of Computer and System Sciences 47 (3): 424–436, 1993] [A. Andersson, M. Thorup, Dynamic ordered sets with exponential search trees. J. ACM 54(3): 13, 2007] Dynamic predecessor searching (w dependent)

Sorting two elements in one word......without comparisons XY test bit w bits

Finding minimum of k elements in one word......without comparisons 7 0x1x1 0x2x2 0x3x3 0x4x4 w bits min(x 1...x 4 )  Searching a sorted set...

Batcher’s bitonic merger 8 [K.E. Batcher, Sorting Networks and Their Applications, AFIPS Spring Joint Computing Conference 1968: ] [S. Albers, T. Hagerup, Improved Parallel Integer Sorting without Concurrent Writing, ACM-SIAM symposium on Discrete algorithms, , 1992] Round 1 Round 2 Round 3 Round 4 increasing sequence decreasing sequence word implementation, O(log #elements) operations Remark: Sorting networks recently revived interest for GPU sorting

van Emde Boas (the idea in the static case) ,0 0,2 2,2 0,2 0,13 13,13 [P. van Emde Boas, R. Kaas, and E. Zijlstra, Design and Implementation of an Efficient Priority Queue, Mathematical Systems Theory 10, , 1977] Universe U ≤ 2 w Predecessor search = find nearest yellow ancestor = binary search on path O(loglog U) min,max Space O(U) 

van Emde Boas (addressing) ,0 0,2 2,2 0,2 0,13 13,13 [P. van Emde Boas, R. Kaas, and E. Zijlstra, Design and Implementation of an Efficient Priority Queue, Mathematical Systems Theory 10, , 1977] Universe U ≤ 2 w min,max array indexing roots by msb bits

van Emde Boas (dynamic) 11 min=0, max= [P. van Emde Boas, R. Kaas, and E. Zijlstra, Design and Implementation of an Efficient Priority Queue, Mathematical Systems Theory 10, , 1977]  1 recursive top-structure and  U bottom structures of the most and least significant log U/2 bits  Keep min & max outside structure  1 recursive call O(loglog U) search & update 9 = 2 ∙ 4 + 1

succ(i) { i = a  n + b } if i > max then return +  if i ≤ min then return min if size ≤ 2 then return max if bottom[a]. size > 0 and bottom[a].max ≥ b then return a  n + bottom[a].succ(b) else if top.max ≤ a then return max c := top.succ(a + 1) return c  n + bottom[c].min 12 delete(i) if size = 2 then if i = max then max := min else min := max if size > 2 then if i = min then i := min := top.min ∙  n + bottom[top.min].min else if i = max then i := max := top.max ∙  n + bottom[top.max].max { i = a  n + b } bottom[a].delete(b) if bottom[a].size = 0 then top.delete(a) size := size – 1 insert(i) if size = 0 then max := min := i if size = 1 then if i < min then min := i else max := i if size ≥ 2 then if i < min then swap(i, min) if i > max then swap(i, max) { i = a  n + b } if bottom[a].size = 0 then top.insert(a) bottom[a].insert(b) size := size + 1 van Emde Boas (pseudo code) O(loglog U) [P. van Emde Boas, R. Kaas, and E. Zijlstra, Design and Implementation of an Efficient Priority Queue, Mathematical Systems Theory 10, , 1977]

van Emde Boas (linear space) 13 [P. van Emde Boas, R. Kaas, and E. Zijlstra, Design and Implementation of an Efficient Priority Queue, Mathematical Systems Theory 10, , 1977] [Dan E. Willard, Log-logarithmic worst-case range queries are possible in space Θ(N), Information Processing Letters 17(2): 81–84, 1983]  Buckets = lists of size O(loglog U), store only bucket minimum in vEB  (Dynamic perfect) Hashing to store all O(n) non-zero nodes of vEB O(n) space, O(loglog U) search min=0, max= = 2 ∙ 4 + 1

O(n∙loglog n) Sorting 14 [M. Thorup, On RAM Priority Queues. ACM-SIAM Symposium on Discrete Algorithms, 59-67, 1996]  loglog n recursive levels of vEB  bottom of recursion log U / log n bit elements  subproblems of k elements stored in k/log n words  mergesort O(k ∙ log k ∙ loglog n / log n) merging 2 words #elements per word merge-sort O(loglog n) priority queue Sorted lists of size 2 i in 2 i /w words ≤ log n min in single word [M. Thorup, On RAM Priority Queues. ACM-SIAM Symposium on Discrete Algorithms, 59-67, 1996] vEB

O(  log n) Dynamic predecessor searching 15  w / 2  log n bit elements  packed B-tree of degree  = 2  log n and height log n / log  =  log n  O(1) time navigation at node [Arne Andersson, Sublogarithmic Searching Without Multiplications. IEEE Foundations of Computer Science, , 1995] [Arne Andersson, Mikkel Thorup, Dynamic Ordered Sets with Exponential Search Trees, J. ACM 54(3): 13, 2007] vEB -  log n recursive levels degree  search keys sorted in one word...

Sorting in O(n) time ? 16

123i…  n 17 Dynamic perfect hashing [Michael L. Fredman, János Komlós, Endre Szemerédi, Storing a Sparse Table with O(1) Worst Case Access Time, J. ACM 31(3): , 1984] [Martin Dietzfelbinger, Anna R. Karlin, Kurt Mehlhorn, Friedhelm Meyer auf der Heide, Hans Rohnert, Robert Endre Tarjan, Dynamic Perfect Hashing: Upper and Lower Bounds, SIAM J. Computing 23(4): , 1994] x h(x)h(x) 123… |Bi|2|Bi|2 x hi(x)hi(x)  2-level hashing of set S of size n  Random hash functions from H: h, h 1, h 2, … (mod table size)  Bucket B i = { x  S | h(x) = i }  Rehash: – whole table if  i |B i | 2  c  n  new table size n – bucket if collision  new bucket size |B i | 2  Search O(1) worst-case & updates O(1) expected amortized  Prime p  U  H = { h k | 0<k<p  h k (x) = k  x mod p }  Pr[ h(x)=h(y) ] = 1/table-size  E[  i |B i | 2 ] = O(n 2 /table-size) no collisions  pr.  (1) no collision in bucket  pr.  (1) total bucket space O(n)  all hash functions new  one new h i