Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我调查了这个 BST,并在算法第一部分讲座中找到了答案。 正如讲座中提到的,删除是执行和效率方面最困难的操作。
但这仅适用于简单的二叉树。 红黑 BST 和另一个呢?
对于 BST(二叉搜索树),搜索和插入都适用于O(log n),
O(log n)
因为它们的工作方式相同..
删除拍摄O(T(Search) + T(Delete-Node)) = O(T(Search) + T(Find-Ancestor) + C)
O(T(Search) + T(Delete-Node)) = O(T(Search) + T(Find-Ancestor) + C)
= O(log n + d)其中d是树高..
= O(log n + d)