Package org.drip.graph.heap
Class BinaryTreePriorityQueue<KEY extends java.lang.Comparable<KEY>,ITEM>
java.lang.Object
org.drip.graph.heap.PriorityQueue<KEY,ITEM>
org.drip.graph.heap.BinaryTreePriorityQueue<KEY,ITEM>
public class BinaryTreePriorityQueue<KEY extends java.lang.Comparable<KEY>,ITEM> extends PriorityQueue<KEY,ITEM>
BinaryTreePriorityQueue implements a Binary Heap Based off of a Binary Tree. The References are:
- Brodal, G. S., G. Lagogiannis, and R. E. Tarjan (2012): Strict Fibonacci Heaps Proceedings on the 44th Symposium on the Theory of Computing - STOC '12 1177-1184
- Cormen, T., C. E. Leiserson, R. Rivest, and C. Stein (2009): Introduction to Algorithms 3rd Edition MIT Press
- Hayward, R., and C. McDiarmid (1991): Average Case Analysis of Heap-building by Repeated Insertion Journal of Algorithms 12 (1) 126-153
- Suchanek, M. A. (2012): Elementary yet Precise Worst-case Analysis of Floyd's Heap Construction Program Fundamenta Informaticae 120 (1) 75-92
- Wikipedia (2020): Binary Heap https://en.wikipedia.org/wiki/Binary_heap
- Module = Computational Core Module
- Library = Graph Algorithm Library
- Project = Graph Optimization and Tree Construction Algorithms
- Package = Heap Based Priority Queue Implementations
- Author:
- Lakshmi Krishnamurthy
-
Constructor Summary
Constructors Constructor Description BinaryTreePriorityQueue(boolean minHeap)BinaryTreePriorityQueue Constructor -
Method Summary
Modifier and Type Method Description java.util.Map<java.lang.Integer,java.util.List<BinaryTreeNode<KEY,ITEM>>>bfsLevelListMap()Perform a BFS Walk and generate the Level List Mapjava.util.List<BinaryTreeNode<KEY,ITEM>>bfsWalk()Perform a BFS Walk through the Heap and retrieve the NodesPriorityQueueEntry<KEY,ITEM>extractExtremum()Extract the Top from the HeapPriorityQueueEntry<KEY,ITEM>extremum()Retrieve the Top from the Heapbooleaninsert(KEY key, ITEM item)Insert the Specified Key/Item into the HeapbooleanisEmpty()Indicate if the Heap is EmptyBinaryTreeNode<KEY,ITEM>keyEntry(KEY key)Retrieve the Node with a Key Corresponding to the InputbooleanmaintainHeapPropertyBottomUp(BinaryTreeNode<KEY,ITEM> node)Maintain the Binary Heap Property from the Node to the TopbooleanmaintainHeapPropertyTopDown(BinaryTreeNode<KEY,ITEM> node)Maintain the Binary Heap Property from the Node to the Bottombooleanmeld(PriorityQueue<KEY,ITEM> priorityQueueOther)Meld the Specified Priority Queue with the CurrentBinaryTreeNode<KEY,ITEM>top()Retrieve the Top NodeMethods inherited from class org.drip.graph.heap.PriorityQueue
delete, minHeap, sortedEntryList, sortedItemList, sortedKeyListMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
BinaryTreePriorityQueue
public BinaryTreePriorityQueue(boolean minHeap)BinaryTreePriorityQueue Constructor- Parameters:
minHeap- TRUE - Indicates that Heap is a Min Heap
-
-
Method Details
-
top
Retrieve the Top Node- Returns:
- The Top Node
-
maintainHeapPropertyBottomUp
Maintain the Binary Heap Property from the Node to the Top- Parameters:
node- Specified Node- Returns:
- TRUE - The Heap Property is successfully maintained
-
maintainHeapPropertyTopDown
Maintain the Binary Heap Property from the Node to the Bottom- Parameters:
node- Specified Node- Returns:
- TRUE - The Heap Property is successfully maintained
-
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
-
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
-
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
-
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
-
bfsWalk
Perform a BFS Walk through the Heap and retrieve the Nodes- Returns:
- The List of Nodes
-
bfsLevelListMap
public java.util.Map<java.lang.Integer,java.util.List<BinaryTreeNode<KEY,ITEM>>> bfsLevelListMap()Perform a BFS Walk and generate the Level List Map- Returns:
- The Level List Map
-
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
-
keyEntry
Retrieve the Node with a Key Corresponding to the Input- Parameters:
key- The Input Key- Returns:
- TRUE - The Node with a Key Corresponding to the Input
-