edu.princeton.cs.algs4.growingtree.interfaces
Interface IDeletingNode<P extends NodeProperties>
- Type Parameters:
P
-
- All Superinterfaces:
- java.lang.Comparable<INode<P>>, IAlgorithmNode<P>, INode<P>
- All Known Implementing Classes:
- ShadowNode
public interface IDeletingNode<P extends NodeProperties>
- extends IAlgorithmNode<P>
This interface is used by IDeleteOperator
to delete a node.
- Author:
- Josh Israel
- See Also:
IDeleteOperator
Methods inherited from interface java.lang.Comparable |
compareTo |
successorHibbardDelete
IAlgorithmNode<P> successorHibbardDelete()
- This performs Hibbard deletion. There are 3 cases:
If the node is a leaf, it is simply removed.
If the node has 1 child, it is replaced by its child
If the node has 2 children, it is swapped with its successor and then deleted
as a node with 1 child or a leaf.
- Returns:
- If a leaf, null. If it has 1 child, returns its child. If it has 2
children, the child of the successor.
predecessorHibbardDelete
IAlgorithmNode<P> predecessorHibbardDelete()
- Identical to successorHibbardDelete, except swaps with predecessor.
- Returns:
- If a leaf, null. If it has 1 child, returns its child. If it has 2
children, the child of the predecessor.