public class MinHeap extends BasicTree
Constructor and Description |
---|
MinHeap()
Basic constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
CreateSearchQueue(ExplicitTreeNode node)
Recursively creates a full queue of tree for breadth-first searching.
|
protected void |
CreateSearchStack(ExplicitTreeNode node)
Recursively creates full stack of tree for depth-first searching.
|
ExplicitTreeNode |
DeleteMin()
Handles removing of min value from heap.
|
protected void |
InsertLeaf(ExplicitTreeNode currentNode,
ExplicitTreeNode parentNode,
ExplicitTreeNode newNode,
boolean leftChild)
Inserts given node as new tree leaf.
|
void |
InsertNode(ExplicitTreeNode newNode)
Attempts to insert provided node at root.
|
protected void |
OrganizeHeap(ExplicitTreeNode updateNode)
Organizes heap by comparing node to parents and swapping TreeNode values if necessary.
|
protected ExplicitTreeNode |
RemoveNode(ExplicitTreeNode aNode,
boolean leftChild)
Removes provided non-root node from tree.
|
ExplicitTreeNode |
SearchBreadthFirst(java.lang.String firstName,
java.lang.String lastName)
Uses a breadth-first search of tree to look for name match.
|
ExplicitTreeNode |
SearchDepthFirst(java.lang.String firstName,
java.lang.String lastName)
Uses a depth-first search of tree to look for name match.
|
protected void |
UpdateChildren(ExplicitTreeNode updateNode)
Recursively updates sizeCounter for self and any potential children.
|
protected void |
UpdateParents(ExplicitTreeNode updateNode)
Recursively updates sizeCounter for any potential parents.
|
CreateNode, GetSubtreeCount, PrintTreeInOrder, PrintTreePostOrder, PrintTreePreOrder, TreeRoot, TreeRoot
public void InsertNode(ExplicitTreeNode newNode)
newNode
- Node to insert.public ExplicitTreeNode DeleteMin()
public ExplicitTreeNode SearchBreadthFirst(java.lang.String firstName, java.lang.String lastName)
firstName
- First name to match.lastName
- Last name to match.public ExplicitTreeNode SearchDepthFirst(java.lang.String firstName, java.lang.String lastName)
firstName
- First name to match.lastName
- Last name to match.protected void InsertLeaf(ExplicitTreeNode currentNode, ExplicitTreeNode parentNode, ExplicitTreeNode newNode, boolean leftChild)
currentNode
- Current node of subtree.parentNode
- Parent of current node.newNode
- New leaf node to insert.leftChild
- Bool to hold if left or right child of parent.protected void OrganizeHeap(ExplicitTreeNode updateNode)
updateNode
- Node to start updating from.protected ExplicitTreeNode RemoveNode(ExplicitTreeNode aNode, boolean leftChild)
aNode
- Non-root node to remove.leftChild
- Boolean to save if node is left or right child of parent.protected void UpdateParents(ExplicitTreeNode updateNode)
updateNode
- Node to start updating from.protected void UpdateChildren(ExplicitTreeNode updateNode)
updateNode
- Node to start updating from.protected void CreateSearchQueue(ExplicitTreeNode node)
node
- Current node to enqueue.protected void CreateSearchStack(ExplicitTreeNode node)
node
- Current node to push.