what are threaded binary trees and adavantages

1
1. What are threaded binary trees? What are the advantages and disadvantages of threaded binary trees over binary search trees? 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 -- Code: 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 pointer to their ansentors .

Upload: pravin2m

Post on 13-Apr-2015

8 views

Category:

Documents


2 download

DESCRIPTION

TY

TRANSCRIPT

Page 1: What Are Threaded Binary Trees and Adavantages

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

A Threaded Binary Tree is a binary tree in which every node that does not have aright child has a THREAD (in actual sense, a link) to its INORDER successor. Bydoing this threading we avoid the recursive method of traversing a Tree, whichmakes 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 --

Code:

struct NODE{struct NODE *leftchild;int node_value;struct NODE *rightchild;struct NODE *thread;}

Advantage1. 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 .Disadvantage1. This makes the Tree more complex .2. More prone to errors when both the child are not present & both values of nodespointer to their ansentors .