Presentation is loading. Please wait.

Presentation is loading. Please wait.

5.9 Heaps of optimal complexity

Similar presentations


Presentation on theme: "5.9 Heaps of optimal complexity"— Presentation transcript:

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 Hasan

2 Heaps of optimal complexity
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.

3 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

4 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.

5 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.

6 Double-ended heap structures ……….

7 Main parts: A min-heap. A max-heap.
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.

8 Operations: Interval heaps………….
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.

9

10 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 .

11 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 .

12 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.

13 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.

14 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.

15 Thank you


Download ppt "5.9 Heaps of optimal complexity"

Similar presentations


Ads by Google