n个树叶中,会产生n+1个多余的NULL空间浪费,因此建立有用的引线。
以中序追踪建立阵列
引线节点左边接中序左空间,右边接中序右空间
无连接之引线向上根结点接(下图范例先以999表示)
在结构左右分别建立储存TF的空间,T为引线,F为小孩
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);
}
}
要求:插入一新节点成为节点 parent 的右小孩(right child )
最大树:树的每个节点都不小於其子树。
最小树:树的每个节点都不大於其子树。
最大堆积树/最小堆叠树:为最大最小树的完全二元树。
void insert_max_heap(element item, int *n){
int i;
if (HEAP_FULL(*n)) {
fprintf(stderr, “堆积已满\n”);
exit(1);
}
i = ++(*n);
while ((i != 1) && (item.key > heap[i/2].key)){heap[i] = heap[i/2];}
heap[i]= item;
}
实作:二元搜寻树的建立、搜寻、插入、删除
【资料结构】二元搜寻树:添加节点
【资料结构】二元搜寻树:删除节点
待补
上一篇我们的基因体时代-AI, Data和生物资讯 Day10-基因疗法中之腺病毒载体与机器学习分享...
MQTT 通讯协定 最後一天就是要把大家领进门, 来把上回的智慧装置串接到 Home Assista...
各位读者大家好~我是Android工程师兼作家 小笠宏树,今天不演别人演我自己。希望大家这个系列看得...
前言 GPU可以利用平行处理的方式,缩短执行时间,因此,这一次就来介绍多执行绪的程序设计方法及应用。...
在上一篇学到了 CSS 的基本语法、使用选择器以及档案的套用方法。接着就让我们来学习如何运用样式属性...