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:
“Science is intimately integrated with the whole social structure and cultural tradition. They mutually support one otheronly in certain types of society can science flourish, and conversely without a continuous and healthy development and application of science such a society cannot function properly.”
—Talcott Parsons (19021979)
“Our major universities are now stuck with an army of pedestrian, toadying careerists, Fifties types who wave around Sixties banners to conceal their record of ruthless, beaverlike tunneling to the top.”
—Camille Paglia (b. 1947)
“At twelve, the disintegration of afternoon
Began, the return to phantomerei, if not
To phantoms. Till then, it had been the other way:
One imagined the violet trees but the trees stood green,
At twelve, as green as ever they would be.
The sky was blue beyond the vaultiest phrase.”
—Wallace Stevens (18791955)