class documentation
class BinaryTree(Tree):
Known subclasses: dsap.trees.linked_binary_tree.LinkedBinaryTree
Abstract base class representing a binary tree structure.
| Method | children |
Generate an iteration of Positions representing p's children. |
| Method | inorder |
Generate an inorder iteration of positions in the tree. |
| Method | left |
Return a Position representing p's left child. |
| Method | positions |
Generate an iteration of the tree's positions. |
| Method | right |
Return a Position representing p's right child. |
| Method | sibling |
Return a Position representing p's sibling (or None if no sibling). |
| Method | _subtree |
Generate an inorder iteration of positions in subtree rooted at p. |
Inherited from Tree:
| Class | |
An abstraction representing the location of a single element within a tree. |
| Method | __iter__ |
Generate an iteration of the tree's elements. |
| Method | __len__ |
Return the total number of elements in the tree. |
| Method | breadthfirst |
Generate a breadth-first iteration of the positions of the tree. |
| Method | depth |
Return the number of levels separating Position p from the root. |
| Method | height |
Return the height of the subtree rooted at Position p. |
| Method | is |
Return True if the tree is empty. |
| Method | is |
Return True if Position p does not have any children. |
| Method | is |
Return True if Position p represents the root of the tree. |
| Method | num |
Return the number of children that Position p has. |
| Method | parent |
Return Position representing p's parent (or None if p is root). |
| Method | postorder |
Generate a postorder iteration of positions in the tree. |
| Method | preorder |
Generate a preorder iteration of positions in the tree. |
| Method | root |
Return Position representing the tree's root (or None if empty). |
| Method | _height |
Return the height of the tree. |
| Method | _height |
Return the height of the subtree rooted at Position p. |
| Method | _subtree |
Generate a postorder iteration of positions in subtree rooted at p. |
| Method | _subtree |
Generate a preorder iteration of positions in subtree rooted at p. |
overrides
dsap.trees.tree.Tree.childrenGenerate an iteration of Positions representing p's children.
overridden in
dsap.trees.linked_binary_tree.LinkedBinaryTreeReturn a Position representing p's left child.
Return None if p does not have a left child.
overridden in
dsap.trees.linked_binary_tree.LinkedBinaryTreeReturn a Position representing p's right child.
Return None if p does not have a right child.