Questions tagged [sets]

Questions about finite and infinite sets and multisets, related data structures and concepts.

Sets have a long history in mathematics and its formalization. Various data structures exists for representing finite and infinite sets and multisets. Sets have close connections to the concept of a function.

442 questions
65
votes
4 answers

What exactly is the semantic difference between set and type?

EDIT: I've now asked a similar question about the difference between categories and sets. Every time I read about type theory (which admittedly is rather informal), I can't really understand how it differs from set theory, concretely. I understand…
user56834
  • 4,244
  • 5
  • 21
  • 35
29
votes
5 answers

Boolean search explained

My mother is taking some online course in order to be a librarian of sorts, in this course they cover boolean searches, so they can search databases efficiently, however, she got a question sounding something like this: The search "x OR y" will…
sch
  • 393
  • 3
  • 5
25
votes
5 answers

Data Structure for Set Intersection?

Is there any data structure that maintain a collection of set (of finite ground set) supporting the following operations? Any sublinear running time will be appreciated? Init an empty set. Add an element to a set. Given two set, report whether they…
Dawei Huang
  • 351
  • 3
  • 4
21
votes
7 answers

in O(n) time: Find greatest element in set where comparison is not transitive

Title states the question. We have as inputs a list of elements, that we can compare (determine which is greatest). No element can be equal. Key points: Comparison is not transitive (think rock paper scissors): this can be true: A > B, B > C, C > A…
James Wierzba
  • 319
  • 2
  • 4
19
votes
1 answer

Problems for which algorithms based on partition refinement run faster than in loglinear time

Partition refinement is a technique in which you start with a finite set of objects and progressively split the set. Some problems, like DFA minimization, can be solved using partition refinement quite efficiently. I don't know of any other problems…
Juho
  • 22,905
  • 7
  • 63
  • 117
18
votes
4 answers

What exactly is the semantic difference between category and set?

In this question, I asked what the difference is between set and type. These answers have been really clarifying (e.g. @AndrejBauer), so in my thirst for knowledge, I submit to the temptation of asking the same about categories: Every time I read…
user56834
  • 4,244
  • 5
  • 21
  • 35
17
votes
4 answers

Given a set of sets, find the smallest set(s) containing at least one element from each set

Given a set $\mathbf{S}$ of sets, I’d like to find a set $M$ such that every set $S$ in $\mathbf{S}$ contains at least one element of $M$. I’d also like $M$ to contain as few elements as possible while still meeting this criterion, although there…
bdesham
  • 277
  • 1
  • 2
  • 9
14
votes
4 answers

Computing set difference between two large sets

I have two large sets of integers $A$ and $B$. Each set has about a million entries, and each entry is a positive integer that is at most 10 digits long. What is the best algorithm to compute $A\setminus B$ and $B\setminus A$? In other words, how…
user917279
  • 241
  • 1
  • 2
  • 5
14
votes
2 answers

Recover a set with the information of the sums of all its subsets

I have a set $S$, which contains $n$ real numbers, which generically are all different. Now suppose I know all the sums of its subsets, can I recover the original set $S$? I have $2^n $ data. This is far more than $n$, the number of unknowns.
S. Kohn
  • 283
  • 1
  • 6
12
votes
3 answers

What is complement of Context-free languages?

I need to know what class of CFL is closed under i.e. what set is complement of CFL. I know CFL is not closed under complement, and I know that P is closed under complement. Since CFL $\subsetneq$ P I can say that complement of CFL is included in…
12
votes
5 answers

How to find the maximal set of elements $S$ of an array such that every element in $S$ is greater than or equal to the cardinality of $S$?

I have an algorithmic problem. Given an array (or a set) $T$ of $n$ nonnegative integers. Find the maximal set $S$ of $T$ such that for all $a\in S$, $a\geqslant |S|$. For example: If $T$=[1, 3, 4, 1, 3, 6], then $S$ can be [3, 3, 6] or [3, 4, 6]…
drzbir
  • 1,000
  • 9
  • 22
11
votes
4 answers

Finding "fingerprint" sets

Let's say we have 10 people, each with a list of favorite books. For a given person X, I would like to find a special subset of X's books liked only by X, i.e. there is no other person that likes all of the books in X's special subset. I think of…
edron79
  • 176
  • 6
11
votes
0 answers

Alternative to Bloom filter for extreme parameters

A Bloom filter is a space-efficient probabilistic data structure to perform membership-tests on a set (see Wikipedia's page for a definition; I use the same notations below). I am interested in a special application where the number of bits per…
11
votes
1 answer

What is a compact way to represent a partition of a set?

There exist efficient data structures for representing set partitions. These data structures have good time complexities for operations like Union and Find, but they are not particularly space-efficient. What is a space-efficient way to represent a…
9
votes
2 answers

Looking for a set implementation with small memory footprint

I am looking for implementation of the set data type. That is, we have to maintain a dynamic subset $S$ (of size $n$) from the universe $U = \{0, 1, 2, 3, \dots , u – 1\}$ of size $u$ with operations insert(x) (add an element x to $S$) and find(x)…
HEKTO
  • 3,173
  • 16
  • 19
1
2 3
29 30