1 / 14

TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A

Number Systems and Data structures Amr Elmasry elmasry@mpi-inf.mpg.de 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.

thais
Télécharger la présentation

TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Number Systems and Data structuresAmr Elmasryelmasry@mpi-inf.mpg.deA. 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

  2. Outline • Some existing number systems • Properties • Data-structural applications • The strictly-regular system • Properties • Application • The quinary-skew system • Properties • Application Elmasry, Amr

  3. What is a Number System? x = <d0,d1,d2,… dk-1> b-ary wj = bj wj = bj+1 – 1 (skew) Examples: • Binary: dj є {0,1}, wj = 2j • Redundant binary: dj є {0,1,2}, wj = 2j • (Canonical) skew binary: The first non-zero digit may be a 2. 0* (ε | 2) (0|1)*, wj = 2j+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. Operations • Extended-RRsystem: dj є {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: dj ≠ 0 • Others: dk-1 = 2 Operations: increment(x,j): s  val(x) + wj decrement(x,j): s  val(x) – wj 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. Properties 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 d0 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 2k-1 (the exponentiality property). Elmasry, Amr

  6. 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) 01200001112012020011 11010001112012020011 02010001112012020011 10110001112012020011 01110001112012020011 Keep track of a list of 2’s from least to most significant. For general increments use Brodal’s guides. Elmasry, Amr

  7. From Number Systems to Data Structures • Define the notion of the rank. • There would be dj objects of rank j in the data structure. • The size of an object of rank j is sj sj =wj  perfect components In general, sj ≤wj (for skew binomial queues 2j ≤ sj ≤2j+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. 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 dj ≥ 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. 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. 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 2r 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. The Skew Five-Symbol Number System dj є {0,1,2,3,4}, wj = 2j+1 – 1 increment by 1: • Increase d0 by 1. • Find the smallest j where dj є {3,4}. • If j exists, perform a fix for dj . fix dj : • Decrease dj by 3. • Increase dj+1 by 1. • If j≠0, Increase dj -1 by 2. A fix does not change the value of a number. Elmasry, Amr

  12. 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. 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. 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. Elmasry, Amr

More Related