Types of Binary Trees
- Single Threaded: each node is threaded towards either the inorder predecessor or successor.
- Double threaded: each node is threaded towards both the inorder predecessor and successor.
In Python:
def parent(node): if node is node.tree.root: return None else: x = node y = node while True: if is_thread(y.right): p = y.right if p is None or p.left is not node: p = x while not is_thread(p.left): p = p.left p = p.left return p elif is_thread(x.left): p = x.left if p is None or p.right is not node: p = y while not is_thread(p.right): p = p.right p = p.right return p x = x.left y = y.rightRead more about this topic: Threaded Binary Tree
Famous quotes containing the words types of, types and/or trees:
“... there are two types of happiness and I have chosen that of the murderers. For I am happy. There was a time when I thought I had reached the limit of distress. Beyond that limit, there is a sterile and magnificent happiness.”
—Albert Camus (19131960)
“If there is nothing new on the earth, still the traveler always has a resource in the skies. They are constantly turning a new page to view. The wind sets the types on this blue ground, and the inquiring may always read a new truth there.”
—Henry David Thoreau (18171862)
“The trees may wish for quiet, but the wind will not subside.”
—Chinese proverb.