5.9 heaps of optimal complexity 5.10 double-ended heap structures and multidimensional heaps 5.11...
TRANSCRIPT
![Page 1: 5.9 Heaps of optimal complexity 5.10 Double-ended heap structures and multidimensional heaps 5.11 Heap-related structures with constant time updates AlShahrani](https://reader030.vdocuments.net/reader030/viewer/2022032522/56649d6e5503460f94a4f5a9/html5/thumbnails/1.jpg)
5.9 Heaps of optimal complexity
5.10 Double-ended heap structures and multidimensional heaps
5.11 Heap-related structures with constant time updates
AlShahrani Hasan
![Page 2: 5.9 Heaps of optimal complexity 5.10 Double-ended heap structures and multidimensional heaps 5.11 Heap-related structures with constant time updates AlShahrani](https://reader030.vdocuments.net/reader030/viewer/2022032522/56649d6e5503460f94a4f5a9/html5/thumbnails/2.jpg)
Heaps of optimal complexityOptimal ? delete_min in O(log n). insert and other operations in constant time.
Steps towards this direction: Fibonacci heap: insert, find_min, merge in O (1)
amortized time and delete_min in O (log n). Pairing heap: O(log n)amortized bounds operations , and
Ω(log log n) amortized lower bound for decrease_key. Relaxed heap: O (1) worst-case for insert and
decrease_key, O (log n) for find_min and delete_min.
![Page 3: 5.9 Heaps of optimal complexity 5.10 Double-ended heap structures and multidimensional heaps 5.11 Heap-related structures with constant time updates AlShahrani](https://reader030.vdocuments.net/reader030/viewer/2022032522/56649d6e5503460f94a4f5a9/html5/thumbnails/3.jpg)
The suggested structure: Brodal Heap.
Worst-case guarantee per-operation
The structure is:
The root has rank 0.Heap-ordered tree. (parent smaller than child )Each node n has a nonnegative rank as balancing information.
Each node has at most one special lower neighbor which might be of arbitrary rank.
“it is quite complicated and not applicable in practice” . Brodal
![Page 4: 5.9 Heaps of optimal complexity 5.10 Double-ended heap structures and multidimensional heaps 5.11 Heap-related structures with constant time updates AlShahrani](https://reader030.vdocuments.net/reader030/viewer/2022032522/56649d6e5503460f94a4f5a9/html5/thumbnails/4.jpg)
Brodal heap structure……..
The other normal neighbors are ordered in increasing rank. And have the following properties :•Each rank less than the rank of n occurs at least once and at most three times.•Between two ranks that occur three times there is a rank that occurs only once. •Before the first rank that occurs three times, there is a rank that occurs only once.
For each node the first lower neighbors of each rank that occurs three times are arranged in a linked list, in increasing order.
![Page 5: 5.9 Heaps of optimal complexity 5.10 Double-ended heap structures and multidimensional heaps 5.11 Heap-related structures with constant time updates AlShahrani](https://reader030.vdocuments.net/reader030/viewer/2022032522/56649d6e5503460f94a4f5a9/html5/thumbnails/5.jpg)
Double-ended heap structures
Two heaps a min-heap and max-heap and insert each element in both linking the two copies by pointers. This means:Insert: two insert operations.One delete-min or delete-max to the corresponding deletion heap and arbitrary deletion in the other heap.
Merge: two merge operations supported.
![Page 7: 5.9 Heaps of optimal complexity 5.10 Double-ended heap structures and multidimensional heaps 5.11 Heap-related structures with constant time updates AlShahrani](https://reader030.vdocuments.net/reader030/viewer/2022032522/56649d6e5503460f94a4f5a9/html5/thumbnails/7.jpg)
Double-ended heap structures ……….
Interval heaps (Group elements in pairs )
Main parts:
A min-heap.A max-heap.A pairing of the elements of the min-heap and the max-heap.At most one unmatched element.
![Page 8: 5.9 Heaps of optimal complexity 5.10 Double-ended heap structures and multidimensional heaps 5.11 Heap-related structures with constant time updates AlShahrani](https://reader030.vdocuments.net/reader030/viewer/2022032522/56649d6e5503460f94a4f5a9/html5/thumbnails/8.jpg)
Interval heaps………….
Operations: Insert : if (there is unmatched element ) {Insert(x)} // pair x with it . Else {unmatched element = x} Find_min: MIN (find-min (min-heap), unmatched element). Find-max: MAX (find-max (max-heap), unmatched element). Delete-min: perform Find_min: MIN (find-min (min-heap), unmatched
element) delete and return the value deleted. Delete-max: perform Find_max: MAX (find-max (max-heap),
unmatched element) delete and return the value deleted. Merge: merge the two min-heaps and merge the two max-heaps. If there
are two unmatched elements, one from each of the merged heaps, it matches them and inserts the smaller one in the min-heap and the larger one in the max-heap.
![Page 9: 5.9 Heaps of optimal complexity 5.10 Double-ended heap structures and multidimensional heaps 5.11 Heap-related structures with constant time updates AlShahrani](https://reader030.vdocuments.net/reader030/viewer/2022032522/56649d6e5503460f94a4f5a9/html5/thumbnails/9.jpg)
![Page 10: 5.9 Heaps of optimal complexity 5.10 Double-ended heap structures and multidimensional heaps 5.11 Heap-related structures with constant time updates AlShahrani](https://reader030.vdocuments.net/reader030/viewer/2022032522/56649d6e5503460f94a4f5a9/html5/thumbnails/10.jpg)
Double-ended heap structures …………
Theorem: there is a double-ended heap that supports insert , find-min , find-max, merge in O(1) ; and delete-min , delete-max in O(log n) worst-case .
![Page 11: 5.9 Heaps of optimal complexity 5.10 Double-ended heap structures and multidimensional heaps 5.11 Heap-related structures with constant time updates AlShahrani](https://reader030.vdocuments.net/reader030/viewer/2022032522/56649d6e5503460f94a4f5a9/html5/thumbnails/11.jpg)
Generalization of the double-ended heap:d-dimensional min-heap:A set of objects, each with d key values in a structure that allows
inserts and query for and deletion of the object with the minimum ith coordinate.
Double-ended heap is a special case of 2-dimensional heap.
Theorem: there is a d-dimensional min-heap that supports insert, find-min and merge in each coordinate in O(1) ; and delete-min in each coordinate in O(log n) worst-case time .
![Page 12: 5.9 Heaps of optimal complexity 5.10 Double-ended heap structures and multidimensional heaps 5.11 Heap-related structures with constant time updates AlShahrani](https://reader030.vdocuments.net/reader030/viewer/2022032522/56649d6e5503460f94a4f5a9/html5/thumbnails/12.jpg)
Heap-related structures with constant time updates
Structures that make updates in faster time than O (log n) 1. Doubled stack : A stack to keep track of the minimum value of elements.Theorem: the doubled stack structure supports push, pop, and find-min in O (1) worst-case time.
![Page 13: 5.9 Heaps of optimal complexity 5.10 Double-ended heap structures and multidimensional heaps 5.11 Heap-related structures with constant time updates AlShahrani](https://reader030.vdocuments.net/reader030/viewer/2022032522/56649d6e5503460f94a4f5a9/html5/thumbnails/13.jpg)
Heap-related structures with constant time updates………..
2. Minqueue: models sliding window over a sequence of items to keep track of the smallest key in the window.
![Page 14: 5.9 Heaps of optimal complexity 5.10 Double-ended heap structures and multidimensional heaps 5.11 Heap-related structures with constant time updates AlShahrani](https://reader030.vdocuments.net/reader030/viewer/2022032522/56649d6e5503460f94a4f5a9/html5/thumbnails/14.jpg)
Minqueue……….
enqueue: enqueue the object in the top queue and remove from the rear of the bottom queue all key larger than the key of the new object.
dequeue.find-min: return the key in the front of the minimum key queue
Theorem: the doubled queue supports enqueue, dequeue and find-min in O (1) amortized time.
http://www.cise.ufl.edu/~sahni/dsaaj/enrich/c13/double.htm
![Page 15: 5.9 Heaps of optimal complexity 5.10 Double-ended heap structures and multidimensional heaps 5.11 Heap-related structures with constant time updates AlShahrani](https://reader030.vdocuments.net/reader030/viewer/2022032522/56649d6e5503460f94a4f5a9/html5/thumbnails/15.jpg)
Thank you