我也没觉得三叉树比二叉树有什么优势。实现复杂度和效率优化的投入产出比不高。感觉应用的也远没有二叉树广。
回复 8楼 beyondyf
没关系,希望有人帮着点评点评,也欢迎测试下。最近比较忙,也没有时间测试,抽了点时间,过来凑凑热闹,呵呵
void tstrie_destroy(TERNARY_TRIE * root) { TERNARY_TRIE * curNode, * delNode; curNode = root->child_trie[TERNARY_MIDDLE]; root->child_trie[TERNARY_MIDDLE] = TSTRIE_NULL; if(curNode == TSTRIE_NULL) return; while(curNode != root) { if(curNode->child_trie[TERNARY_LEFT] != TSTRIE_NULL) { curNode = curNode->child_trie[TERNARY_LEFT]; curNode->parent->child_trie[TERNARY_LEFT] = TSTRIE_NULL; } else if(curNode->child_trie[TERNARY_MIDDLE] != TSTRIE_NULL) { curNode = curNode->child_trie[TERNARY_MIDDLE]; curNode->parent->child_trie[TERNARY_MIDDLE] = TSTRIE_NULL; } else if(curNode->child_trie[TERNARY_RIGHT] != TSTRIE_NULL) { curNode = curNode->child_trie[TERNARY_MIDDLE]; curNode->parent->child_trie[TERNARY_MIDDLE] = TSTRIE_NULL; } else { delNode = curNode; curNode = curNode->parent; TSTRIE_DELNODE(delNode); } } }