Package org.drip.graph.softheap
Class KaplanZwickPriorityQueue<KEY extends java.lang.Comparable<KEY>,ITEM>
java.lang.Object
org.drip.graph.heap.PriorityQueue<KEY,ITEM>
org.drip.graph.softheap.KaplanZwickPriorityQueue<KEY,ITEM>
public class KaplanZwickPriorityQueue<KEY extends java.lang.Comparable<KEY>,ITEM> extends PriorityQueue<KEY,ITEM>
KaplanZwickPriorityQueue implements the Soft Heap described in Kaplan and Zwick (2009). The
References are:
- Chazelle, B. (2000): The Discrepancy Method: Randomness and Complexity https://www.cs.princeton.edu/~chazelle/pubs/book.pdf
- Chazelle, B. (2000): The Soft Heap: An Approximate Priority Queue with Optimal Error Rate Journal of the Association for Computing Machinery 47 (6) 1012-1027
- Chazelle, B. (2000): A Minimum Spanning Tree Algorithm with Inverse-Ackerman Type Complexity Journal of the Association for Computing Machinery 47 (6) 1028-1047
- Kaplan, H., and U. Zwick (2009): A simpler implementation and analysis of Chazelle's Soft Heaps https://epubs.siam.org/doi/abs/10.1137/1.9781611973068.53?mobileUi=0
- Pettie, S., and V. Ramachandran (2008): Randomized Minimum Spanning Tree Algorithms using Exponentially Fewer Random Bits ACM Transactions on Algorithms 4 (1) 1-27
- Module = Computational Core Module
- Library = Graph Algorithm Library
- Project = Graph Optimization and Tree Construction Algorithms
- Package = Soft Heap - Approximate Priority Queue
- Author:
- Lakshmi Krishnamurthy
-
Constructor Summary
Constructors Constructor Description KaplanZwickPriorityQueue(boolean minHeap, int r, KaplanZwickTree<KEY,ITEM> head, KaplanZwickTree<KEY,ITEM> tail)KaplanZwickPriorityQueue Constructor -
Method Summary
Modifier and Type Method Description PriorityQueueEntry<KEY,ITEM>extractExtremum()Extract the Top from the HeapPriorityQueueEntry<KEY,ITEM>extremum()Retrieve the Top from the HeapKaplanZwickTree<KEY,ITEM>head()Retrieve the Head of the List of TreesdoubleimpliedErrorRate()Compute the Implied Error Ratestatic <KEY extends java.lang.Comparable<KEY>, ITEM>
KaplanZwickPriorityQueue<KEY,ITEM>Initial(boolean minHeap, int r, PriorityQueueEntry<KEY,ITEM> entry)Construct an Initial Heap with a single Entrybooleaninsert(KEY key, ITEM item)Insert the Specified Key/Item into the HeapbooleanisEmpty()Indicate if the Heap is Emptybooleanmeld(PriorityQueue<KEY,ITEM> priorityQueueOther)Meld the Specified Priority Queue with the Currentstatic <KEY extends java.lang.Comparable<KEY>, ITEM>
KaplanZwickPriorityQueue<KEY,ITEM>Meld(KaplanZwickPriorityQueue<KEY,ITEM> queue1, KaplanZwickPriorityQueue<KEY,ITEM> queue2)Meld the Queue Pair into a Queueintr()Retrieve the R Parameterintrank()Retrieve the Rank of the HeapKaplanZwickTree<KEY,ITEM>tail()Retrieve the Tail of the List of Treesjava.lang.StringtoString()Methods inherited from class org.drip.graph.heap.PriorityQueue
delete, minHeap, sortedEntryList, sortedItemList, sortedKeyListMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
KaplanZwickPriorityQueue
public KaplanZwickPriorityQueue(boolean minHeap, int r, KaplanZwickTree<KEY,ITEM> head, KaplanZwickTree<KEY,ITEM> tail) throws java.lang.ExceptionKaplanZwickPriorityQueue Constructor- Parameters:
minHeap- TRUE - Indicates that Heap is a Min Heapr- R Parameterhead- The Head Tree of the Heaptail- The Tail Tree of the Heap- Throws:
java.lang.Exception- Thrown if the Inputs are Invalid
-
-
Method Details
-
Meld
public static <KEY extends java.lang.Comparable<KEY>, ITEM> KaplanZwickPriorityQueue<KEY,ITEM> Meld(KaplanZwickPriorityQueue<KEY,ITEM> queue1, KaplanZwickPriorityQueue<KEY,ITEM> queue2)Meld the Queue Pair into a Queue- Type Parameters:
KEY- Key TypeITEM- Item Type- Parameters:
queue1- Queue #1queue2- Queue #2- Returns:
- The Melded Queue
-
Initial
public static <KEY extends java.lang.Comparable<KEY>, ITEM> KaplanZwickPriorityQueue<KEY,ITEM> Initial(boolean minHeap, int r, PriorityQueueEntry<KEY,ITEM> entry)Construct an Initial Heap with a single Entry- Type Parameters:
KEY- Key TypeITEM- Item Type- Parameters:
minHeap- TRUE - Indicates that Heap is a Min Heapr- The R Parameterentry- The Entry- Returns:
- The Initial Heap with a single Entry
-
head
Retrieve the Head of the List of Trees- Returns:
- Head of the List of Trees
-
tail
Retrieve the Tail of the List of Trees- Returns:
- Tail of the List of Trees
-
r
public int r()Retrieve the R Parameter- Returns:
- The R Parameter
-
rank
public int rank()Retrieve the Rank of the Heap- Returns:
- Rank of the Heap
-
meld
Description copied from class:PriorityQueueMeld the Specified Priority Queue with the Current- Specified by:
meldin classPriorityQueue<KEY extends java.lang.Comparable<KEY>,ITEM>- Parameters:
priorityQueueOther- The Specified Binary Tree Priority Queue- Returns:
- TRUE - The Specified Priority Queue successfully melded
-
insert
Description copied from class:PriorityQueueInsert the Specified Key/Item into the Heap- Specified by:
insertin classPriorityQueue<KEY extends java.lang.Comparable<KEY>,ITEM>- Parameters:
key- Keyitem- Node Item- Returns:
- TRUE - The Key/Item successfully inserted
-
isEmpty
public boolean isEmpty()Description copied from class:PriorityQueueIndicate if the Heap is Empty- Specified by:
isEmptyin classPriorityQueue<KEY extends java.lang.Comparable<KEY>,ITEM>- Returns:
- TRUE - The Heap is Empty
-
extremum
Description copied from class:PriorityQueueRetrieve the Top from the Heap- Specified by:
extremumin classPriorityQueue<KEY extends java.lang.Comparable<KEY>,ITEM>- Returns:
- The Top Key in the Heap
-
extractExtremum
Description copied from class:PriorityQueueExtract the Top from the Heap- Specified by:
extractExtremumin classPriorityQueue<KEY extends java.lang.Comparable<KEY>,ITEM>- Returns:
- The Top Key in the Heap
-
impliedErrorRate
public double impliedErrorRate()Compute the Implied Error Rate- Returns:
- The Implied Error Rate
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-