小编Ani*_*niq的帖子

使用 AVL 树和二叉树的该算法的时间复杂度是多少

考虑以下使用二叉搜索树对 n 个元素的列表进行排序的算法:

initialise t to be an empty binary search tree
for each element x in the list,
  add x to t
while t is not empty,
  remove and print the smallest element of t
Run Code Online (Sandbox Code Playgroud)

如果使用以下方法实现树,则该算法的最坏情况时间复杂度是多少:

a) 普通的二叉搜索树?
b) AVL 树?

我的解决方案:我认为解决方案是,对于 AVL 树:O(Log N) 而对于 BST,它将是 O(N)

algorithm avl-tree binary-search-tree

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

algorithm ×1

avl-tree ×1

binary-search-tree ×1