# Meldable DEPQs

Data Structure AlgorithmsAnalysis of AlgorithmsAlgorithms

• A meldable DEPQ (MDEPQ) is defined as a DEPQ (Double Ended Priority Queue) that, in addition to the DEPQ operations listed above, includes the operation meld(p, q) ... meld the DEPQs p and q into a single DEPQ. The result of melding the double-ended priority queues p and q is a single double-ended priority queue that contains all elements of p and q. The meld operation is destructive in that following the meld, p and q do not remain as independent DEPQs.
• To meld two DEPQs in less than linear time, it is necessary that the DEPQs be represented implementing explicit pointers (rather than implicit ones as in the array representation of a heap) as otherwise a linear number of elements necessary to be moved from their initial to their ﬁnal locations.
• It can be shown that when the min-max pair heap is represented in such a way, an element (size of n) DEPQ may be melded with another element(size of k) (where k<=n) in O(log(n/k)*log k) time.
• It can be shown that the complexity of melding two min-max heaps of size a and b, respectively, is Ω(a + b).
• An MDEPQ implementation that permits one to calculate the min and max elements, insert an element, and meld two priority queues in O(1) time. The time required to delete the minimum or maximum element is O(log n).
• It can be shown that leftist trees may be adapted to get a simple representation for MDEPQs in which meld consumes logarithmic time and the remaining operations have the same asymptotic complexity as when any of the aforementioned DEPQ representations is implemented.
• It is interesting to note that if we implement the FMPQ (Fast Meldable Priority Queue) structure of as the base MPQ structure, we obtain a total correspondence MDEPQ structure in which removeMax and removeMin consume logarithmic time, and the remaining operations consume constant time. This adaptation is excellent as compare to the dual priority queue adaptation because the space requirements are almost half. Additionally, the total correspondence adaptation is faster than dual priority queue adaptation.
Published on 03-Jan-2020 05:47:02