# Threaded Binary Tree in Data Structure

If a binary tree has n number of nodes, then the total number of links in the tree is 2n and the total number of NULL links is n+1. A.J. Perlis and C. Thorton jointly proposed an idea to make effective use of these NULL pointers. The basic idea is to replace the NULL pointers with some appropriate pointer values called Threaded Binary Tree.

The general rule is to replace the NULL left pointer of a node with the address of the immediate predecessor of this node and replace the NULL right pointer of a node with the address of the immediate successor of this node.
In the Threaded Binary Tree still, the left pointer of node D and the right pointer of node H is NULL.

## Algorithm for find Inorder Successor of Threaded Binary Tree:

```Algorithm fnFindInorder_Successor(x)
{
p=x->ptrRight;
p=p->ptrLeft;
return p;
}  // End of Algorithm
```

## Algorithm for find Inorder Predecessor of Threaded Binary Tree:

```Algorithm fnFindInorder_Predecessor(x)
{
p=x->ptrLeft;
p=p->ptrRight;
return p;
}  // End of Algorithm
```

## Algorithm for Inorder Traversal of Threaded Binary Tree:

```ALgorithm fnInorder(H)
{