Slideshow

Monday 25 February 2013


What are threaded binary trees? What are the advantages and disadvantages of
threaded binary trees over binary search trees? 

Ans :
A Threaded Binary Tree is a binary tree in which every node that does not have a
right child has a THREAD (in actual sense, a link) to its INORDER successor. By
doing this threading we avoid the recursive method of traversing a Tree, which
makes use of stacks and consumes a lot of memory and time.
The node structure for a threaded binary tree varies a bit and its like this --
struct NODE
{
struct NODE *leftchild;
int node_value;
struct NODE *rightchild;
struct NODE *thread;
}

Advantage
1. By doing threading we avoid the recursive method of traversing a Tree , which
makes use of stack and consumes a lot of memory and time .
2 . The node can keep record of its root .
Disadvantage
1. This makes the Tree more complex .
2. More prone to errors when both the child are not present & both values of nodes

No comments:

Post a Comment