Meldable Priority Queues and Skew Heaps
Meldable Priority Queues
A randomized meldable heap (also Meldable Heap or Randomized Meldable Priority Queue) is defined as a priority queue based data structure in which the underlying structure is also a heap-ordered binary tree. However, there are no hard and fast rules on the shape of the underlying binary tree.
- This approach has a number of facilities i.e. advantages over similar data structures.
- It offers simpler approach than other data structures.
- All operations for the randomized meldable heap are easy to apply and the constant factors in their complexity bounds are small.
- There is also no requirement to preserve balance conditions and no satellite information within the nodes is needed.
- Lastly, this structure exhibits good worst-case time efficiency. Mostly the execution time of each individual operation is logarithmic with high probability.
A skew heap (or self – adjusting heap) is defined as a heap data structure implemented as a binary tree.
Skew heaps are advantageous because of they are able to merge more quickly than binary heaps.
Unlike binary heaps, there are no structural constraints, so there is no guarantee that the height of the tree is logarithmic.
Only two conditions must be satisfied −
- The general heap order must be maintained there (root is minimum and same is recursively true for subtrees), but balanced property (all levels must be full except the last) is not needed.
- Main operation in Skew Heaps is only Merge. We can implement other operations like insert, extractMin(), etc associated with Merge only.
Let the skew heap 1 to be
The second heap to be assumed
And we obtain the final merged tree in the form of
Recursive Merge Process
Let a1 and a2 be the two min skew heaps to be merged. Let a1’s root be smaller than a2’s root (If not smaller, we can swap to get the same).
We swap a1->left and a1->right.
a1->left = merge(a2, a1->left)
Published on 02-Jan-2020 11:26:21