3

Assume ordered sets that support O(n) iteration and O(log n) access to single items, what is theoretically optimal complexity for set-union, set-intersection and set-difference? Assume that a dedicated structure could be used for the sets, as long as the result is of the same type as the input.

Edit:

Let n be the size of the larger set, m the size of the smaller set and d the size of the symmetric difference.

An algorithm is described in this paper. It runs in O(m*log(n/m)) which is claimed to be optimal. The algorithm is then modified in this paper so that it also becomes O(d*log(n/d)).

Is it a contradiction that an optimal algorithm can be improved? I guess not since d is a new parameter, O(m*log(n/m)) is still optimal with respect to n and m. But is this the end or how fast is possible?

smossen
  • 887
  • 6
  • 11
  • 2
    What are your suggestions so far? Sounds like homework. Think how you would implement `set-union`, `set-intersection` and `set-difference` using the given set interface. – MrSmith42 Aug 27 '13 at 09:23
  • 1
    The best algorithm I have found so far run in O(min(m*log(n/m),d*log(n/d)), where n is the size of the larger set, m is the size of the smaller set and d is the size of the symmetric difference. But is this optimal or can it be improved further? – smossen Aug 27 '13 at 11:04
  • You can't get that running time unless the abstract data type has more operations than you've admitted to. – David Eisenstat Aug 27 '13 at 13:39
  • It is assumed the items can be compared and hashed in O(1). Do you have other operations in mind? – smossen Aug 27 '13 at 14:34

0 Answers0