📄 7-5.c
字号:
#include "stdio.h"
typedef char Datatype;
typedef struct threaded_tree *pt_threaded;
typedef struct threaded_tree {
short int left_thread;
pt_threaded left_child;
Datatype data;
pt_threaded right_child;
short int right_thread;
};
pt_threaded succ( pt_threaded tree)
{ //在线索二叉树中找到结点的中序前驱
pt_threaded temp;
temp = tree->right_child;
if ( !tree->right_thread )
while( !temp->left_child )
temp = temp->left_child;
return temp;
}
void right_insert(pt_threaded parent,pt_threaded child)
{ //在线索二叉树中插入结点,使之成为父结点的右孩子*/
pt_threaded temp;
child->right_child=parent->right_child;
child->right_thread=parent->right_thread;
child->left_child=parent;
child->left_thread=1;
parent->right_child=child;
parent->right_thread=0;
if ( !child->right_thread ) {
temp = succ(child);
temp->left_child = child;
}
}
void main()
{
pt_threaded p,c;
right_insert(p,c);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -