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:
“Two children, all alone and no one by,
Holding their tattered frocks, throan airy maze
Of motion lightly threaded with nimble feet
Dance sedately; face to face they gaze,
Their eyes shining, grave with a perfect pleasure.”
—Laurence Binyon (18691943)
“Some say that happiness is not good for mortals, & they ought to be answered that sorrow is not fit for immortals & is utterly useless to any one; a blight never does good to a tree, & if a blight kill not a tree but it still bear fruit, let none say that the fruit was in consequence of the blight.”
—William Blake (17571827)