Binary Tree Terms#
A tree has a
root node has no parent nodes.
leaf node has zero children.
lef node is an
external node, non leaf node are
degree of a node is the number of children of that node.
The lines between nodes are called
Binary Tree Characteristics#
- In a binary tree, each node has a maximum of two children.
- In a classic binary tree there is one root.
- There is only one unique path from any node to the root
An empty tree has no nodes, and should be considered a binary tree.
def __init__(self, value):
self.value = value
self.left = None
self.right = None
A Full Binary Tree#
Every node that has a descendant has two descendants.
A Complete Binary Tree#
When we fill out the tree we go from top to bottom and then left to right. All levels are completely filled out except the lowest level nodes which are filled from as left as possible.
A Perfect Binary Tree#
All nodes with descendants have two descendants and all leaves are on the same level.
Height or Depth#
A tree height is the number of
edges to reach the furthest
height of a particular
node is the number of edges to reach the
root is at
level of a node is the number of edge to traverse to reach the
node from the
root is at level 0.