Questions tagged [set-union]

In set theory, the union (denoted by ∪) of a collection of sets is the set of all distinct elements in the collection. It is one of the fundamental operations through which sets can be combined and related to each other. In C++, set_union() constructs a sorted range consisting of all elements present in one or both sorted input ranges.

90 questions
0
votes
2 answers

How to take union of matrix rows that are represented by another vector?

I want to take the union of some of the rows of a matrix x. The row numbers of the rows whose union has to be taken are given by vector r. Is there any built-in function in MATLAB that can do it? x = [1 2 4 0 0; 3 6 5 0 0; 7 8 10…
Tariq Islam
  • 97
  • 10
0
votes
1 answer

does std set_union always take common elements from first

When there are common elements in two arrays, does std set_union always take those common elements from the first array? From the code snippet below it shows it always picks common elements from the first array, but is this guaranteed? How to make…
Daneil
  • 3
  • 1
0
votes
2 answers

combine keys of hashes for output (outer join of hashes)

I'm analysing a log file with Perl 5.8.8.[1] I'm searching for days that expose some of two trigger patterns, maybe one of it, maybe both (I changed the actual patterns in the code snippet shown below). I'm interested in the count of occurrences per…
Wolf
  • 9,679
  • 7
  • 62
  • 108
0
votes
2 answers

C++ - String Array Parameter for SetUnion function

I wrote a function to compute the union of two sets. I'm running into several compilation errors and I believe that's in part due to how I made the StringUnion array and declared it but nothing I do is working thus far. This is my header file.…
TigerCode
  • 315
  • 3
  • 15
0
votes
0 answers

Solving intersect and union formula between four sets

I am trying to figure out how ( b ^ cd ^ ab ) is converted to ( bc u bd ), can anyone one explain to me how the first formula was converted to the second one? As shown in the photo below:
SMH
  • 1,276
  • 3
  • 20
  • 40
0
votes
1 answer

Union Set using MapReduce MongoDB

I'm trying to unite two collections using MapReduce. They have identical structure, for example: db.tableR.insert({product:"A", quantity:150}); db.tableR.insert({product:"B", quantity:100}); db.tableR.insert({product:"C",…
0
votes
2 answers

Forming the union of two sets seems to give wrong and inconsistent answers

The following code is my attempt to form the union of the two element set {2,3} with the empty set {}. I expect that the resulting container (in this case, a list) should have size 2. However, when I run the code, I get that the size of the union…
sitiposit
  • 149
  • 1
  • 13
0
votes
2 answers

Combinations of triangles that form a convex hull

I have a set of triangles. I am looking for a way to find all combinations of these triangles that constitute a convex hull when joined together. The convex hull should be empty, ie. no points inside the convex hull only on the edge. And only…
bonna
  • 1,575
  • 2
  • 17
  • 31
0
votes
1 answer

Lisp: to perform set union operation

I 'am a beginner in LISP.I use clisp in ubuntu.I have a code here in lisp to carry out union operation on two lists.The logic is correct.But stuck at an error which is: *** - APPEND: A proper list must not end with T my code is: (defun set-union (L1…
Midhun
  • 744
  • 2
  • 15
  • 31
0
votes
1 answer

Compare lists Unions

List A = new List(); List B = new List(); List itemsremoved = ((A∩B)^c)-A; List itemsadded = ((A∩B)^c)-B; I want to know how to do a complement of the union A & B minus the elements of a list. Is…
sheepiiHD
  • 421
  • 2
  • 16
0
votes
2 answers

set_union issue while using arrays

I am trying to get union of 4 arrays using set_union. Here is the code I have so far: int setA[5] = {2, 4, 5, 7, 8}; int setB[7] = {1, 2, 3, 4, 5, 6, 7}; int setC[5] = {2, 5, 8, 8, 15}; int setD[6] = {1, 4, 4, 6, 7, 12}; int AunionB[12]; int…
Ankush
  • 6,767
  • 8
  • 30
  • 42
0
votes
3 answers

How to find union of n vector?

I have a 2-D vector of hyperedges as well as an adjacency list. I have to find the union of hyperEdges[i].size() vectors, but I can only find the union of just two vectors. What improvement can I make to my code below to do this? I want to store the…
Shravan40
  • 8,922
  • 6
  • 28
  • 48
0
votes
1 answer

Can we find the path between 2 node if they are connected using union-find algo?

I studied the union find algo and found it is very useful in following ways. to find out if 2 node are connected or not to compress the path. (save space) if the problem is to find if 2 node connected or not , then we can use…
Suri
  • 3,287
  • 9
  • 45
  • 75
0
votes
0 answers

Creating set functions union, difference, intersection in SML

I'm trying to write three function definitions that can be used to manipulate sets in SML. As you can see we are basing the implementation on lists. Union is the set of all elements in both Set s and Set t. (No duplicates are allowed) Intersection…
0
votes
1 answer

C++ STL set_union gets error vector iterator + offset out of range

I am attempting to merge several vectors to create a resulting vector that is the union of the elements in the input vectors, using STL in C++. Each input is already in sorted order, and the elements are unsigned short. I am getting an error…
Woody20
  • 791
  • 11
  • 30