Typedef Enum pointertag {link, thread };
Typedef struct {
Char ch;
Int num;
} Elemtype;
Typedef struct {
Bithrnode * lchild, * rchild;
Pointertag ltag, rtag;
Elemtype data;
} Bithrnode, * bithree;
// Records the binary tree of clues in the middle order traversal.
Void inthreading (bithree & P, bithree & Pre ){
If (p ){
Inthreading (p-> lchild, pre );
If (! (P-> lchild )){
P-> lchild = pre;
P-> ltag = thread;
}
If (! (Pre-> rchild )){
Pre-> rtag = thread;
Pre-> rchild = P;
}
Pre = P;
Inthreading (p-> rchild, pre );
}
}
// Create a complete clue Binary Tree
Int inorderthreading (bithree & Thr, bithree & T ){
Bithrnode * P, * pre;
If (! Thr = (bithree) malloc (sizeof (bithrnode) Exit (1 );
Thr-> rchild = thr;
Thr-> rtag = thread;
Pre = thr;
If (! T) {Thr-> lchild = thr; exit (1 );}
Thr-> lchild = T;
P = T;
Inthreading (p, pre );
Pre-> rchild = thr;
Pre-> rtag = thread;
Thr-> rchild = pre;
Return 0;
}
// Traverse the clue Binary Tree in non-recursive central order.
Int inordertraverse_thr (bithree & T ){
If (! T) Exit (1 );
Bithrnode * P = T-> lchild;
While (P! = T ){
While (p-> ltag = link) P = p-> lchild;
If (visit (p) return 1;
While (p-> rtag = thread & P-> rchild! = T)
{
P = p-> rchild;
Visit (p-> rchild );
}
P = p-> rchild;
}
Return 0;
}
Data Structure-clue Binary Tree