非不相交集合并集的最佳算法是什么?

编程入门 行业动态 更新时间:2024-10-12 10:23:23
本文介绍了非不相交集合并集的最佳算法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

让我们说有两个(非不相交)点集(笛卡尔空间),执行两个集的并集的最佳情况复杂度算法是什么?

Lets say there are two (non disjoint) sets of points (cartesian space), what is the best case complexity algorithm to perform the union of the two sets ?

推荐答案

由于点坐标是任意的,并且它们之间没有特殊关系,因此我不认为此问题是特定于几何的问题.有效地将S1和S2合并为新集合S是普遍的问题.

Since the point coordinates are arbitrary and there is no special relation between them, I don't see this problem as a geometric specific problem. It is the generic problem of efficiently merging S1 and S2 into a new set S.

我知道两种选择:

1)当集合存储在哈希表中(实际上是哈希集),则联合将O(| S1 | + | S2 |)取为平均值.

1) When the sets are stored in a hash table (actually a hash set), the union takes O(|S1|+|S2|) in average.

2)如果将结构存储在平衡搜索树中,则可以假设| S1 |> | S2 |,则达到最坏情况O(| S1 | * Log(| S1 |))的时间.

2) If you store the structures in a balanced search tree, you can achieve a worst case time of O(|S1| * Log(|S1|)), assuming that |S1|>|S2|.

更多推荐

非不相交集合并集的最佳算法是什么?

本文发布于:2023-10-24 20:40:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524949.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:算法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!