[英]Find element greater than given in partially ordered set
I have a set S
of elements of type T
. 我有一组S
类型的元素的T
。 There is a partial order <=
on elements of type T
. 类型T
元素上存在偏序<=
。 It is known, that all elements in S
are not ordered. 众所周知, S
中的所有元素都不是有序的。 Then, I need a way to perform the following query: having element e
of type T
, find e'
in S
such that e <= e'
. 然后,我需要一种方法来执行以下查询: 具有类型T
元素e
,在S
找到e'
,使得e <= e'
。
Is there a datastructure, that allows to perform such queries efficiently (without linear scan of S
) ? 是否有一个数据结构可以有效地执行此类查询(无需对S
进行线性扫描)?
Important note: T
is complete lattice. 重要说明: T
是完整晶格。
You could preprocess the list and find subset of elements which don't have any other elements greater than those numbers (assume you represented all the numbers as a dag, you should find all the elements that have no parents). 您可以对列表进行预处理,找到没有其他元素大于这些数字的元素子集(假设您将所有数字表示为dag,则应该找到所有没有父元素的元素)。 Once you have that subset all you need to do is a linear scan on this subset. 一旦有了该子集,您需要做的就是对该子集进行线性扫描。 I don't think you can do better than this. 我认为您不能做得更好。
Additionally, you could also sort this subset by the number of elements each of these elements in the subset are greater than (in decreasing order). 另外,您还可以按元素数量对子集进行排序,子集中的每个元素都大于(按降序排列)。 And scan the elements in order. 并按顺序扫描元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.