Binary search tree over AVL tree

前端 未结 4 1988
没有蜡笔的小新
没有蜡笔的小新 2020-12-31 20:35

As far as I know the time complexity between AVL trees and Binary Search Trees are the same in average case, with AVLs beating BSTs in worst case scenarios. This gives me a

4条回答
  •  無奈伤痛
    2020-12-31 20:56

    AVL tree is also a BST but it can rebalance itself. This behavior makes it faster in worst cases. It keeps rebalancing itself so in worst case it will consume O(log n ) time when the plain BST will take O(n). So, the answer to your question: It is always better to implement AVL tree than just plain BST.

提交回复
热议问题