[英]What are the differences between segment trees, interval trees, binary indexed trees and range trees?
What are differences between segment trees, interval trees, binary indexed trees and range trees in terms of:段树、区间树、二叉索引树和范围树在以下方面有什么区别:
Please do not just give definitions.请不要只给出定义。
All these data structures are used for solving different problems:所有这些数据结构都用于解决不同的问题:
Performance / Space consumption for one dimension:一维的性能/空间消耗:
(k is the number of reported results). (k 是报告结果的数量)。
All data structures can be dynamic, in the sense that the usage scenario includes both data changes and queries:所有数据结构都可以是动态的,因为使用场景包括数据更改和查询:
Higher dimensions (d>1):更高维度(d>1):
Not that I can add anything to Lior's answer , but it seems like it could do with a good table.并不是说我可以在Lior 的回答中添加任何内容,但似乎可以用一张好桌子来做。
k
is the number of reported results k
是报告结果的数量
Operation![]() |
Segment![]() |
Interval![]() |
Range![]() |
Indexed![]() |
---|---|---|---|---|
Preprocessing![]() |
n logn![]() |
n logn![]() |
n logn![]() |
n logn![]() |
Query![]() |
k+logn ![]() |
k+logn ![]() |
k+logn ![]() |
logn![]() |
Space![]() |
n logn![]() |
n ![]() |
n ![]() |
n ![]() |
Insert/Delete![]() |
logn![]() |
logn![]() |
logn![]() |
logn![]() |
d > 1
Operation![]() |
Segment![]() |
Interval![]() |
Range![]() |
Indexed![]() |
---|---|---|---|---|
Preprocessing![]() |
n(logn)^d ![]() |
n logn![]() |
n(logn)^d ![]() |
n(logn)^d ![]() |
Query![]() |
k+(logn)^d ![]() |
k+(logn)^d ![]() |
k+(logn)^d ![]() |
(logn)^d ![]() |
Space![]() |
n(logn)^(d-1) ![]() |
n logn![]() |
n(logn)^(d-1)) ![]() |
n(logn)^d ![]() |
The bounds for preprocessing and space for segment trees and binary indexed trees can be improved:可以改进段树和二叉索引树的预处理范围和空间:
2n
space and subsequently built in 2n = O(n)
using dynamic programming, if you forgo adding intervals at any arbitrary point: https://cp-algorithms.com/data_structures/segment_tree.html#toc-tgt-62n
空间中,然后使用动态规划在2n = O(n)
构建,如果您放弃在任意点添加间隔: https : //cp-algorithms.com/data_structures/segment_tree.html#toc- TG-6n
, see this answer: Is it possible to build a Fenwick tree in O(n)? n
中构建,请参阅此答案: Is it possible to build a Fenwick tree in O(n)?O(log(n))
time O(log(n))
时间内的操作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.