第18讲查找.pptVIP

  • 2
  • 0
  • 约6.19千字
  • 约 53页
  • 2015-08-16 发布于广东
  • 举报
30 20 10 40 35 25 23 key = 48 , f 四、二叉排序树的查找 查找算法 template class ElemType, class KeyType BinTreeNodeElemType *BinarySortTreeElemType, KeyType::SearchHelp(const KeyType key, BinTreeNodeElemType *f) const { BinTreeNode ElemType *p = GetRoot(); f = NULL; while (p != NULL p-data != key) { if (key p-data) { f = p; p = p-leftChild; } else { f = p; p = p-rightChild; } } return p; } 30 20 10 40 35 25 23 key = 48 p f f p f p 30 20 10 40 35 25 23 key = 22 p f p f f p f p f p 四、二叉排序树的查找 3、二叉排序树的插入 插入思想: 若二叉排序树为空,则插入结点应为新的根结点;否则,继续在其左、右子树上查找,直至某个叶子结点的左子树或右子树为空为止,则

文档评论(0)

1亿VIP精品文档

相关文档