void InOrderThreat(BiThrTree thrt)
//thrt是指向中序全線索化頭結點的指針本算法中序遍歷該二叉樹
{p=thrt>lchild; //p指向二叉樹的根結點當二叉樹為空時p指向thrt
whild(p!=thrt)
{while(p>ltag==) p=p>lchild;//沿左子女向下
visit(*p);//訪問左子樹為空的結點
while(p>rtag== && p>rchild!=thrt){p=p>rchild;visit(*p);}//沿右線索訪問後繼結點
p=p>rchild;//轉向右子樹
} }//結束InOrderThread
[題目分析]若使新插入的葉子結點S成T右子樹中序序列的第一個結點則應在T的右子樹中最左面的結點(設為p)處插入使S成為結點p的左子女則S的前驅是T後繼是p
void ThrTreeInsert(BiThrTree TS)
//在中序線索二叉樹T的右子樹上插入結點S使S成為T右子樹中序遍歷第一個結點
{p=T>rchild; //用p去指向T的右子樹中最左面的結點
while(p>ltag==) p=p>lchild;
S>ltag=;S>rtag=; //S是葉子其左右標記均為
S>lchild=T;S>rchild=p;//S的前驅是根結點T後繼是結點p
p>lchild=S;p>ltag=; //將p的左子女指向S 並修改左標志為
}//結束 ThrTreeInsert
[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
From:http://tw.wingwit.com/Article/program/sjjg/201311/23701.html