algorithm - 比 BST 更快地找到继任者、前任

标签 algorithm time-complexity binary-search-tree

我正在寻找具有以下属性的数据结构: 对于整数列表(例如 x > 1,且 x < U,其中 U 是一个大整数)。

它可以执行:predecessor(x), successor(x), insert(x), delete(x)

这可以用二叉搜索树来实现,所有操作都是 O(log n)。好吧,据我的教授说,这可以在 O(log log U) 时间内用 successor 和 predecessor 实现,在 O(log log U) 时间内用 insertdelete O(log U) 时间。

它需要一个大小为 U 的数组和一个二叉搜索树。谁知道这个算法是什么?

最佳答案

查看 Y-Fast TrieX-Fast Trie

我相信这些就是您要找的。

来自维基百科:

Y-快速特里:

In computer science, a y-fast trie is a data structure for storing integers from a bounded > > domain. It supports exact and predecessor or successor queries in time O(log log M), using O(n) > space, where n is the number of stored values and M is the maximum value in the domain.

极速特里:

In computer science, an x-fast trie is a data structure for storing integers from a bounded > domain. It supports exact and predecessor or successor queries in time O(log log M), using O(n > log M) space, where n is the number of stored values and M is the maximum value in the domain.

关于algorithm - 比 BST 更快地找到继任者、前任,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25783159/

相关文章:

algorithm - 找到一条通过任意节点序列的最短路径?

c++ - 计算while循环的运行时间

时间复杂度的算法回顾

algorithm - 二叉搜索树-删除

java - java中BST中给定元素的递归中序后继

python - 我简单的 tftp 客户端背后的逻辑有缺陷吗?

arrays - 算法:寻找第k1,k2,k3个最大子数组和

C - 使用后序遍历释放二叉树的内存

java - 有些测试用例没有运行,但有些是概率测试

c - 为什么这个函数的空间复杂度是m*n?