Threaded Binary Trees.
Threaded Binary Trees.
Node Format In Threaded Binary Trees:
LTAG
|
LEFT
|
DATA
|
RIGHT
|
RTAG
|
⇒For Threaded Binary tree:
if Ltag==0 ⇒ left points to inorder predecessor.
if Ltag==1 ⇒ left points to left child.
if Rtag==0 ⇒ right points to inorder sucessor.
if Rtag==1 ⇒ right points to right child.
Find in-order sucessor in-order threaded binary tree:
psuedo code to find in-order successor:
threaded BT * p;
if(rtag==0)
{
successor is p->right;
}
else
{
p=p->right;
while(p->ltag==1)
p=p->left;
}
return p;
Diagram:
Comments
Post a Comment