typedef struct threaded_tree *threaded_pointer;
typedef struct threaded_tree{
short int left_thread;
threaded_pointer left_child;
char data;
threaded_pointer right_child;
short int right_child;
};
//한노드의 중위 후속자를 찾는 함수
threaded_pointer insucc(threaded_pointer tree){
threaded_pointer temp;
temp=tree->right_child;
if(!tree->right_thread)
while(!temp->left_thread)
temp=temp->left_child;
return temp;
}
//스레드이진트리의 중위순회
void tinorder(threaded_pointer tree){
threaded_pointer temp=tree;
for( ; ; ){
temp = insucc(temp);
if(temp = tree) break;
printf("%3c",temp->data);
}
}
//스레드 이진 트리에서의 오른쪽삽입
void insert_right(threaded_pointer parent, threaded_pointer child){
threaded_pointer temp;
child->right_child=parent->right_child;
child->right_thread=parent->right_thread;
child->left_child=parent;
child->left_thread=TRUE;
parent->right_child = child;
parent->right_thread = FALSE;
if(!child->right_thread){
temp=insucc(child);
temp->left_child=child;
}
}