Interface BinaryTree<T>

Type Parameters:
T - type of BinaryTree labels
All Superinterfaces:
BinaryTreeKernel<T>, Iterable<T>, Standard<BinaryTree<T>>
All Known Implementing Classes:
BinaryTree1, BinaryTreeSecondary

public interface BinaryTree<T> extends BinaryTreeKernel<T>
BinaryTreeKernel enhanced with secondary methods.
  • Method Details

    • root

      T root()
      Reports the root of this.
      Returns:
      the root entry of this
      Aliases:
      reference returned by root
      Requires:
      this /= empty_tree
      Ensures:
      there exists left, right: binary tree of T
          (this = compose(root, left, right))
    • replaceRoot

      Replaces the root of this with x, 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

      int height()
      Reports the height of this.
      Returns:
      the height
      Ensures:
      height = ht(this)
    • inOrderAssemble

      void inOrderAssemble(T root, BinaryTree<T> left, BinaryTree<T> right)
      Assembles in this a tree that has the same in-order traversal as a tree with root label root and subtrees left and right; the declaration notwithstanding, the dynamic type of left and right must be the same as the dynamic type of this.
      Parameters:
      root - the root label
      left - the left subtree
      right - the right subtree
      Aliases:
      reference root
      Updates:
      this
      Clears:
      left, right
      Ensures:
      IN_ORDER(this) = IN_ORDER(compose(root, #left, #right))