在给定范围内找到前身的数据结构
给出了键的列表,说[2、6、4、9、3],我如何找到一个元素的前身,只剩下元素的索引?例如,
- 6的前身应该是2,而不是4,因为4在6的右边。4
- 的前身应为2,而不是3。
我们知道,在平衡的二进制搜索树中,我们可以找到前身和继任者给定O(log n)时间复杂性中的键,但这并不是我想要的。
我似乎想要一个数据结构,并具有来自BST和间隔树的功能。 但是我不知道如何结合它们。
Given a list of keys, says [2, 6, 4, 9, 3], how can I find the predecessor of an element, with index left to the element only? For example
- The predecessor of 6 should be 2, not 4, because 4 is on the right of 6.
- The predecessor of 4 should be 2, not 3.
We know that in a balanced binary search tree, we can find predecessor and successor for given key in O(log n) time complexity, but that is not exactly what I wanted.
I seems like I wanted a data structure with functions from both BST and Interval Tree.
But I don't know how to combine them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论