class documentation

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_inorder Generate an inorder iteration of positions in subtree rooted at p.

Inherited from Tree:

Class Position 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_empty Return True if the tree is empty.
Method is_leaf Return True if Position p does not have any children.
Method is_root Return True if Position p represents the root of the tree.
Method num_children 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_bad Return the height of the tree.
Method _height_good Return the height of the subtree rooted at Position p.
Method _subtree_postorder Generate a postorder iteration of positions in subtree rooted at p.
Method _subtree_preorder Generate a preorder iteration of positions in subtree rooted at p.
def children(self, p):

Generate an iteration of Positions representing p's children.

def inorder(self):

Generate an inorder iteration of positions in the tree.

def left(self, p):

Return a Position representing p's left child.

Return None if p does not have a left child.

def positions(self):

Generate an iteration of the tree's positions.

def right(self, p):

Return a Position representing p's right child.

Return None if p does not have a right child.

def sibling(self, p):

Return a Position representing p's sibling (or None if no sibling).

def _subtree_inorder(self, p):

Generate an inorder iteration of positions in subtree rooted at p.