You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.2 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

二叉排序树又称二叉排序树。它或者是一个空树,或者是一个具有下列性质的二叉树:

  • 若它的左子树不空,则左子树上所有节点的值均小于它的根结构的值
  • 若它的右子树不空,则右子树上所有结点的值均大于它的根节点的值
  • 它的左、右子树也分别是二叉排序树

!20190311150104225.png

BST以链接方式存储保持了链接存储结构在执行插入或删除操作时不用移动元素的优点只要找到合适的插入和删除位置后仅需要修改链接指针即可。插入删除的时间性能比较好。而对于BST的查找其比较次数等于给定值的结点在二叉排序树的层数极端情况下最少为1次最多不会超过树的深度。也就是说BST的查找性能取决于BST的形状。
我们希望二叉排序树是比较平衡的,其深度与完全二叉树相同,均为\log_{2}nlog2n + 1那么查找的时间复杂度也就为O(logn)近似于折半查找。这就引申出一个问题即如何让BST平衡化

模拟AVL树插入及自平衡过程 AVL Tree Visualzation (usfca.edu)