Number Systems and Data structures Amr Elmasry A. Elmasry, C. Jensen and J. Katajainen, The strictly-regular number system and worst-case.

Slides:



Advertisements
Similar presentations
Turning Amortized to Worst-Case Data Structures: Techniques and Results Tsichlas Kostas.
Advertisements

COL 106 Shweta Agrawal and Amit Kumar
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.
Transform and Conquer Chapter 6. Transform and Conquer Solve problem by transforming into: a more convenient instance of the same problem (instance simplification)
Advanced Data structure
Rank-Pairing Heaps Robert Tarjan, Princeton University & HP Labs Joint work with Bernhard Haeupler and Siddhartha Sen, ESA
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.
CS 315 March 24 Goals: Heap (Chapter 6) priority queue definition of a heap Algorithms for Insert DeleteMin percolate-down Build-heap.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu.
Binary Heaps CSE 373 Data Structures Lecture 11. 2/5/03Binary Heaps - Lecture 112 Readings Reading ›Sections
1 Pertemuan 20 Binomial Heap Matakuliah: T0026/Struktur Data Tahun: 2005 Versi: 1/1.
Rank-Pairing Heaps Bernhard Haeupler, Siddhartha Sen, and Robert Tarjan, ESA
Nick Harvey & Kevin Zatloukal
CSE 373 Data Structures Lecture 12
Source: Muangsin / Weiss1 Priority Queue (Heap) A kind of queue Dequeue gets element with the highest priority Priority is based on a comparable value.
General Trees and Variants CPSC 335. General Trees and transformation to binary trees B-tree variants: B*, B+, prefix B+ 2-4, Horizontal-vertical, Red-black.
0 Course Outline n Introduction and Algorithm Analysis (Ch. 2) n Hash Tables: dictionary data structure (Ch. 5) n Heaps: priority queue data structures.
5.9 Heaps of optimal complexity
Melding Priority Queues Ran Mendelson Robert E. Tarjan Mikkel Thorup Uri Zwick SWAT 2004.
Binomial Heaps Jyh-Shing Roger Jang ( 張智星 ) CSIE Dept, National Taiwan University.
CSE 326: Data Structures Binomial Queues Ben Lerner Summer 2007.
1 Binomial heaps, Fibonacci heaps, and applications.
The Power of Incorrectness A Brief Introduction to Soft Heaps.
§8 Binomial Queues Haven’t we had enough about queues? What is a binomial queue for? Well, what is the average time for insertions with leftist or skew.
Binomial Queues Text Read Weiss, §6.8 Binomial Queue Definition of binomial queue Definition of binary addition Building a Binomial Queue Sequence of inserts.
The Binary Heap. Binary Heap Looks similar to a binary search tree BUT all the values stored in the subtree rooted at a node are greater than or equal.
Chapter 6 Binary Trees. 6.1 Trees, Binary Trees, and Binary Search Trees Linked lists usually are more flexible than arrays, but it is difficult to use.
Computer Sciences Department1. Sorting algorithm 3 Chapter 6 3Computer Sciences Department Sorting algorithm 1  insertion sort Sorting algorithm 2.
B + -Trees Same structure as B-trees. Dictionary pairs are in leaves only. Leaves form a doubly-linked list. Remaining nodes have following structure:
„Policy-Based Benchmarking of Weak Heaps and Their Relatives“ Asger Bruun*, Stefan Edelkamp, Jyrki Katajainen*, Jens Rasmussen* *University of Copenhagen.
Sorting. Pseudocode of Insertion Sort Insertion Sort To sort array A[0..n-1], sort A[0..n-2] recursively and then insert A[n-1] in its proper place among.
2-3 Tree. Slide 2 Outline  Balanced Search Trees 2-3 Trees Trees.
An experimental study of priority queues By Claus Jensen University of Copenhagen.
Balanced Search Trees Problem: Efficiency of BST is related to tree’s height.  search, insert and remove follow a path from root to desired location 
WEEK 3 Leftist Heaps CE222 Dr. Senem Kumova Metin CE222_Dr. Senem Kumova Metin.
Data Structure & Algorithm II.  In a multiuser computer system, multiple users submit jobs to run on a single processor.  We assume that the time required.
Union Find ADT Data type for disjoint sets: makeSet(x): Given an element x create a singleton set that contains only this element. Return a locator/handle.
1 Binomial Tree Binomial tree. n Recursive definition: B k-1 B0B0 BkBk B0B0 B1B1 B2B2 B3B3 B4B4.
Data Structure II So Pak Yeung Outline Review  Array  Sorted Array  Linked List Binary Search Tree Heap Hash Table.
Queues, Stacks and Heaps. Queue List structure using the FIFO process Nodes are removed form the front and added to the back ABDC FrontBack.
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.
Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at
CMSC 341 Binomial Queues and Fibonacci Heaps. Basic Heap Operations OpBinary Heap Leftist Heap Binomial Queue Fibonacci Heap insertO(lgN) deleteMinO(lgN)
Internal and External Sorting External Searching
Priority Queues CS 110: Data Structures and Algorithms First Semester,
1 Fibonacci heaps: idea List of multiway trees which are all heap-ordered. Definition: A tree is called heap-ordered if the key of each node is greater.
Priority Queues CS /02/05 L7: PQs Slide 2 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved.
Fibonacci Heaps. Fibonacci Binary insert O(1) O(log(n)) find O(1) N/A union O(1) N/A minimum O(1) O(1) decrease key O(1) O(log(n)) delete O(log(n) O(log(n))
Partially Ordered Data ,Heap,Binary Heap
Self-Adjusting Data Structures
Lecture ? The Algorithms of Kruskal and Prim
Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008
Data Structures Binomial Heaps Fibonacci Heaps Haim Kaplan & Uri Zwick
Binomial heaps, Fibonacci heaps, and applications
Splay Trees Binary search trees.
Source: Muangsin / Weiss
Insert in amortized cost O(1), Merge in O(lgn) DeleteMax in O(lgn)
Priority Queues MakeQueue create new empty queue
Selection in heaps and row-sorted matrices
Persistent deques.
A simpler implementation and analysis of Chazelle’s
ערמות בינומיות ופיבונצ'י
Closing a Classical Data Structure Problem Gerth Stølting Brodal
Strict Fibonacci Heaps
Melding Priority Queues
Binomial heaps, Fibonacci heaps, and applications
Union-Find with Constant Time Deletions
Binomial heaps, Fibonacci heaps, and applications
CS 6310 Advanced Data Structure Wei-Shian Wang
Priority Queues Binary Heaps
Presentation transcript:

Number Systems and Data structures Amr Elmasry A. Elmasry, C. Jensen and J. Katajainen, The strictly-regular number system and worst-case efficient data structures. A. Elmasry, C. Jensen and J. Katajainen, The magic of a number system.  TexPoint fonts used in EMF.  Read the TexPoint manual before you delete this box.: AAA

Elmasry, Amr 2 Number Systems and Data Structures Outline Some existing number systems Properties Data-structural applications The strictly-regular system Properties Application The quinary-skew system Properties Application

Elmasry, Amr 3 Number Systems and Data Structures What is a Number System? x = b-ary w j = b j w j = b j+1 – 1 (skew) Examples: Binary: d j є {0,1}, w j = 2 j Redundant binary: d j є {0,1,2}, w j = 2 j (Canonical) skew binary: The first non-zero digit may be a 2. 0* (ε | 2) (0|1)*, w j = 2 j+1 – 1 [Myers 83] Redundant-regular (RR) binary: Every 2 is preceded by at least one 0. (0 | 1 | 01*2)* [Clancy & Knuth 77]

Elmasry, Amr 4 Number Systems and Data Structures Operations Extended-RR system: d j є {0,1,2,3}.Every 3 is preceded by at least one {0,1}, and every 0 is preceded by at least one {2,3}. [Clancy & Knuth 77 - Kaplan et al. 02] Zeroless systems: d j ≠ 0 Others: d k-1 = 2 Operations: increment(x,j): s  val(x) + w j decrement(x,j): s  val(x) – w j add(x,y): s  val(x) + val(y) cut(x,j): cut x into two valid sequences. concatenate(x,y): concatenate x and z and return a valid sequence.

Elmasry, Amr 5 Number Systems and Data Structures Properties Increments involve amortized constant digit flips in binary system. But, worst-case constant digit flips for the RR system. Increments and decrements only at d 0 involve constant digit flips in the skew-binary system. Increments and decrements involve worst-case constant digit flips when using two back-to back RR system. Increments and decrements involve worst-case constant digit flips for the extended-RR system. The sum of digits of a k-digit number in the RR binary system is at most k. The sum of digits of a k-digit number in the zeroless-RR binary system is at most 2k. The sum of digits of a k-digit number in the extended-RR binary system is at most 2k. The value of a k-digit number in the zeroless RR binary system is at least 2 k -1 (the exponentiality property).

Elmasry, Amr 6 Number Systems and Data Structures How does it Work? Example: RR-binary system (least-significant digit first) Increment least significant bit + fix least significant 2 fix-carry: 2 x  0 (x+1) Keep track of a list of 2’s from least to most significant. For general increments use Brodal’s guides.

Elmasry, Amr 7 Number Systems and Data Structures From Number Systems to Data Structures Define the notion of the rank. There would be d j objects of rank j in the data structure. The size of an object of rank j is s j s j = w j  perfect components In general, s j ≤ w j (for skew binomial queues 2 j ≤ s j ≤ 2 j+1 – 1 ) fix-carry resembles a join of b objects of rank j to one of rank j+1. fix-borrow resembles a split of an object of rank j to b objects of rank j-1.

Elmasry, Amr 8 Number Systems and Data Structures Worst-Case Efficient Data Structures Finger trees. [Guibas et al. 77] Using the RR-binary system: binomial queues with constant worst-case insertion cost. [Carlsson et al. 88] Using the skew-binary system: skew binomial queues with constant worst-case insertion cost. [Brodal & Okasaky 96] Using the zeroless-RR system: a priority queue that supports meld in constant worst-case cost. [Brodal 95] Using two RR-systems back-to-back with d j ≥ 2: both meld and decrease in constant worst-case cost. [Brodal 96] Using two RR-systems back-to-back: purely functional catenable deques in constant worst-case cost per operation. [Kaplan & Tarjan 95] Using the extended-RR system: Fat heaps. [Kaplan et al. 02] Using the extended-RR system: worst-case efficient priority queue with the working-set property. [Elmasry 06]

Elmasry, Amr 9 Number Systems and Data Structures The Strictly-Regular System Every 2 is preceded by a 0, and every 0 is preceded by a 2, except for the last block that starts with a 0. (1 + | 01*2)* (ε | 01*) Primitives: fix-carry: 2 x  0 (x+1) fix-borrow: 0 x  2 (x-1) Deciding which digit to fix depends on the value of the current digit (digit under operation) and the next extreme digit (0 or 2). Properties: Increments, decrements, catenations and cuts involve worst-case constant digit flips. All can be implemented in worst-case constant time once you know the closest extreme digit. Addition of k-digit numbers involve k+O(1) carry propagations. The sum of digits of a k-digit number is either k or k-1 (compactness). The value of a k-digit number is at least Φ k (exponentiality).

Elmasry, Amr 10 Number Systems and Data Structures Strictly-Regular Trees The rank of a node equals the number of its children. The ranks of the children of a node form a strictly-regular sequence. Properties: A strictly-regular tree of rank r has at least 2 r nodes. Adding a subtree with a non-larger rank or detaching a subtree is done in worst-case constant time if one can access the trees whose ranks resemble the adjacent extreme digits. Splitting and concatenating sequences of children can be done worst-case efficiently. Application: Improving the constant factors for the number of comparisons of data structures. For meldable heaps (no decrease) delete-min requires at most 2 lg n +O(1) comparisons instead of 7 lg n + O(1).

Elmasry, Amr 11 Number Systems and Data Structures The Skew Five-Symbol Number System d j є {0,1,2,3,4}, w j = 2 j+1 – 1 increment by 1: 1.Increase d 0 by 1. 2.Find the smallest j where d j є {3,4}. 3.If j exists, perform a fix for d j. fix d j : 1.Decrease d j by 3. 2.Increase d j+1 by 1. 3.If j≠0, Increase d j -1 by 2. A fix does not change the value of a number.

Elmasry, Amr 12 Number Systems and Data Structures Properties Numbers from one to thirty: 1, 2, 01, 11, 21, 02, 12, 22, 03, 301, 111, 211, 021, 121, 221, 031, 302, 112, 212, 022, 122, 222, 032, 303,113, 2301, 0401, 3111,1211, 2211 A decrement is implemented as an inverse of an increment, by using an undo stack to remember where the fixes were performed. Properties: (Any number is composed of a sequence of blocks each ends with a 3 or 4 and the last subsequence is the tail) The body of a block ending with 4 comprises either 0 or 12*1. The body of a block ending with 3 comprises either 0, 12*1, or 2*. Each 4, 23 and 33 is followed by either 0 or 1. There can be at most one 0 in the tail, which must be its first digit. The sum of digits of a k-digit number is at most 2k.

Elmasry, Amr 13 Number Systems and Data Structures Application The fix is done in constant worst-case time: The minimum root is detached from its tree and attached as the root of the other two trees forming a larger tree. Application: A priority queue can be implemented as a forest of complete binary trees having worst-case costs: O(1) insert and O(lg n) deletemin.

Elmasry, Amr 14 Number Systems and Data Structures Conclusions and Future Work: Conclusions Number systems are interesting. The connection between number systems and worst-case-efficient data structures is efficacious. Two new number systems were introduced. Future work New number systems with applications. More applications for the strictly-regular system. Extending the strictly-regular system to be ternary (b-ary). Is it possible to implement general increments and decrements in worst-case constant cost for the strictly-regular binary system? Supporting decrements for the skew five-symbol system without the usage of the undo stack.