two-tier relaxed heaps presented by claus jensen joint work with amr elmasry and jyrki katajainen...
DESCRIPTION
3 Worst-case complexity bounds The number of element comparisons performed in the worst case Run-relaxed heaps Fat heaps Find-minO(1) InsertO(1) DecreaseO(1) Delete3lg n + O(1)2.6lg n + O(1)TRANSCRIPT
![Page 1: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/1.jpg)
Two-tier relaxed heaps
Presented by Claus JensenJoint work with Amr Elmasry and Jyrki Katajainen
Slides available atwww.cphstl.dk
![Page 2: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/2.jpg)
2
Heaps
• Our focus has been on the worst-case comparison complexity of the heap operations:– Find-min– Insert– Decrease(-key)– Delete
• The following heaps support decrease at O(1) cost in the worst case:– Run-relaxed heaps (Driscoll et al. 1988) – Fat heaps (Kaplan and Tarjan 1999)
![Page 3: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/3.jpg)
3
Worst-case complexity bounds• The number of element comparisons performed in the
worst case
Run-relaxed heaps
Fat heaps
Find-min O(1) O(1)Insert O(1) O(1)Decrease O(1) O(1)Delete 3lg n + O(1) 2.6lg n + O(1)
![Page 4: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/4.jpg)
4
Our two-tier relaxed heaps• A two-tier relaxed heap has the following complexity
bounds.
Number of element comparisons
Worst-casecost
Find-min O(1) O(1)
Insert O(1) O(1)Decrease O(1) O(1)
Delete lg n + 3lglg n + O(1) O(lg n)
![Page 5: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/5.jpg)
5
Two-tier relaxed heaps
• A two-tier relaxed heap is composed of two run-relaxed heaps relying on a redundant zeroless representation
• Next: Number representations vs. data structures
![Page 6: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/6.jpg)
6
A binomial heap using binary representation
• M = 111two Digits = {0, 1}
• A binomial heap storing 7 integers which are kept in 3 binomial trees and stored in heap order within the trees
• The rank of a binomial tree is equal to the number of children of the root
![Page 7: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/7.jpg)
7
A binomial heap using redundant binary representation
• M = 202redundant two Digits = {0, 1, 2}
• A binomial heap storing 10 integers
![Page 8: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/8.jpg)
8
A binomial heap using redundant zeroless representation
• M = 214redundant four Digits = {1, 2, 3, 4}
• A binomial heap storing 14 integers
![Page 9: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/9.jpg)
9
Zeroless number system
• Addition– M + 1– Corresponds to inserting a node into the
binomial heap
• Subtraction– M – 1– Corresponds to extracting a node from the
binomial heap
![Page 10: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/10.jpg)
10
Insert and extract• Using functionality which incrementally handles
carries and borrows in the zeroless number system, both addition and subtraction can be accomplished at constant cost
• When using a carry/borrow stack to provide this functionality in the context of binomial heaps, both insert and extract can be performed at constant worst-case cost
• Next: Run-relaxed heaps
![Page 11: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/11.jpg)
11
Run-relaxed heaps• A run-relaxed heap is composed of relaxed
binomial trees which are almost heap-ordered binomial trees
• Some nodes can be marked active indicating that there may be a heap-order violation
• The maximum number of active nodes is lg n (Driscoll et al. 1988)
• A singleton is an active node which has no active siblings
• A run is a sequence of consecutive active siblings
![Page 12: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/12.jpg)
12
Run-relaxed heaps• A series of run/singleton
transformations is used to reduce the number of active nodes
• Illustrated with one of the singleton transformations
![Page 13: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/13.jpg)
13
A run-relaxed heap
• A run-relaxed heap storing 10 integers. The relaxed binomial trees are drawn in schematic form and active nodes are drawn in grey
![Page 14: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/14.jpg)
14
Two-tier relaxed heap components
• A two-tier relaxed heap has the following components:– An upper store which contains pointers to
roots and active nodes held in the lower store– A lower store which contains the elements of
the heap• The two components are run-relaxed
heaps using the redundant zeroless number system
![Page 15: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/15.jpg)
15
A two-tier relaxed heap
• A two-tier relaxed heap storing 12 integers
![Page 16: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/16.jpg)
16
Extra functionality at the upper store
• Lazy deletions: Sometimes nodes in the upper store are marked instead of being deleted – When the number of marked nodes reaches
half of the total number of nodes, the marked nodes are removed by an incremental global rebuilding
![Page 17: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/17.jpg)
17
Heap operations
• Find-min: – The upper-store find-
min operation is called, and this operation returns either one of the roots or one of the active nodes
![Page 18: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/18.jpg)
18
Heap operations• Insert:
– The lower-store insert operation is called which adds a new node to the lower store
– A pointer to that node is inserted into the upper store
– If due to a join of two trees a node is no longer a root, the pointer in the upper store associated with that node is marked
![Page 19: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/19.jpg)
19
Heap operations• Decrease:
– After the element replacement the node is made active
– If the number of active nodes has become too large, a constant number of transformations (singleton or run) is performed
– A pointer to the node is inserted into the upper store
![Page 20: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/20.jpg)
20
Heap operations• Delete:
– Lower store: The node is removed. A node is extracted, and this node and the roots of the former subtrees are joined together into a new tree
– If deletion involves an internal node, the new root of the subtree is made active
– Upper store: A pointer to the new root is inserted. If there exists a pointer to the removed node, it is deleted.
![Page 21: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/21.jpg)
21
New contribution
• The introduction of extract• Improved constant factors for delete
![Page 22: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/22.jpg)
22
Open problems
• Constant factors for the find-min, insert, and decrease operations should be improved
• Can the bound for delete be improved to log n + O(1)? (this can be obtained when decrease is not supported)
![Page 23: Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at](https://reader036.vdocuments.site/reader036/viewer/2022062523/5a4d1acf7f8b9ab059970c16/html5/thumbnails/23.jpg)
23
Related work
• Amr Elmasry, Claus Jensen, and Jyrki Katajainen. Relaxed weak queues: an alternative to run-relaxed heaps. CPH STL Report 2005-2
• Amr Elmasry, Claus Jensen, and Jyrki Katajainen. On the power of structural violations in priority queues. CPH STL Report 2005-3
• Both available at www.cphstl.dk