Threaded Binary Tree

A threaded binary tree defined as follows:

"A binary tree is threaded by making all right child pointers that would normally be null point to the inorder successor of the node, and all left child pointers that would normally be null point to the inorder predecessor of the node."

A threaded binary tree makes it possible to traverse the values in the binary tree via a linear traversal that is more rapid than a recursive in-order traversal. It is also possible to discover the parent of a node from a threaded binary tree, without explicit use of parent pointers or a stack, albeit slowly. This can be useful where stack space is limited, or where a stack of parent pointers is unavailable (for finding the parent pointer via DFS).

To see how this is possible, consider a node k that has a right child r. Then the left pointer of r must be either a child or a thread back to k. In the case that r has a left child, that left child must in turn have either a left child of its own or a thread back to k, and so on for all successive left children. So by following the chain of left pointers from r, we will eventually find a thread pointing back to k. The situation is symmetrically similar when q is the left child of p—we can follow q's right children to a thread pointing ahead to p.

Read more about Threaded Binary Tree:  Types of Binary Trees, The Array of Inorder Traversal, Example, Null Link, Non Recursive Inorder Traversal For A Threaded Binary Tree

Famous quotes containing the words threaded and/or tree:

    It was a tangled and perplexing thicket, through which we stumbled and threaded our way, and when we had finished a mile of it, our starting-point seemed far away. We were glad that we had not got to walk to Bangor along the banks of this river, which would be a journey of more than a hundred miles. Think of the denseness of the forest, the fallen trees and rocks, the windings of the river, the streams emptying in, and the frequent swamps to be crossed. It made you shudder.
    Henry David Thoreau (1817–1862)

    The pine tree seems to listen, the fir tree seems to wait, and neither with impatience:Mthey give no thought to the little people below them whose impatience and curiosity eat them up alive.
    Friedrich Nietzsche (1844–1900)