Binary search tree
1.特 性
2.操作
TreeNode* BST::Search(int KEY){
TreeNode *current = root; // 將curent指向root作為traversal起點
while (current != NULL && KEY != current->key) {
// 兩種情況跳出迴圈:
// 1.沒找到 2.有找到
if (KEY < current->key{
current = current->leftchild; // 向左走
} else {
current = current->rightchild; // 向右走
}
}
return current;
}Last updated