Interface BinaryTree<T>
- Type Parameters:
T- type ofBinaryTreelabels
- All Superinterfaces:
BinaryTreeKernel<T>, Iterable<T>, Standard<BinaryTree<T>>
- All Known Implementing Classes:
BinaryTree1, BinaryTreeSecondary
BinaryTreeKernel enhanced with secondary methods.-
Method Summary
Modifier and TypeMethodDescriptionintheight()Reports the height ofthis.voidinOrderAssemble(T root, BinaryTree<T> left, BinaryTree<T> right) Assembles inthisa tree that has the same in-order traversal as a tree with root labelrootand subtreesleftandright; the declaration notwithstanding, the dynamic type ofleftandrightmust be the same as the dynamic type ofthis.replaceRoot(T x) Replaces the root ofthiswithx, and returns the old root.root()Reports the root ofthis.Methods inherited from interface BinaryTreeKernel
assemble, disassemble, sizeMethods inherited from interface Iterable
forEach, iterator, spliteratorMethods inherited from interface Standard
clear, newInstance, transferFrom
-
Method Details
-
root
-
replaceRoot
Replaces the root ofthiswithx, and returns the old root.- Parameters:
x- the new root- Returns:
- the old root
- Aliases:
- reference
x - Updates:
this- Requires:
this /= empty_tree- Ensures:
there exists left, right: binary tree of T (#this = compose(replaceRoot, left, right) and this = compose(x, left, right))
-
height
-
inOrderAssemble
Assembles inthisa tree that has the same in-order traversal as a tree with root labelrootand subtreesleftandright; the declaration notwithstanding, the dynamic type ofleftandrightmust be the same as the dynamic type ofthis.- Parameters:
root- the root labelleft- the left subtreeright- the right subtree- Aliases:
- reference
root - Updates:
this- Clears:
left, right- Ensures:
IN_ORDER(this) = IN_ORDER(compose(root, #left, #right))
-