Questions tagged [set-intersection]

The intersection of two or more sets consists of the elements that those sets all have in common.

Set intersection is a mathematical operation defined upon sets.
The intersection of two or more sets is defined as the set of those elements that are present in all sets.

For example, let A = { 2, 3, 4 } and B = { 2, 4, 5 }.
The intersection of A and B is what the set of elements that A and B have in common: { 2, 4 }.
The symbol for intersection is ∩, so in our example we would write A ∩ B = { 2, 4 }

276 questions
0
votes
0 answers

Obtaining the minimum number of sets

I have an interesting problem that others mot likely have run into at one point. I will be doing this in Java and figuring out the code, but first I need to figure out the best algorithm (or AN algorithm). I have several groups (g1, g2, g3, g4, g5,…
Tony
  • 1,127
  • 1
  • 18
  • 29
0
votes
1 answer

Python 3.4 set intersection

I am trying to understand why my intersection does not return an empty list when I run this code. n = ([1,2,3,4,5],[3,4,5,6],[5,6,7],[7,8,9,10,11,12],[10,22,33,44,45]) w = set(n[0]).intersection(*n[:1]) print(w) #Returns (1,2,3,4,5) However this…
Dennis Simpson
  • 85
  • 1
  • 10
0
votes
2 answers

Combining the common elements in two lists in R, using only logical and arithmetic operators

I'm currently attempting to work out the GCD of two numbers (x and y) in R. I'm not allowed to use loops or if, else, ifelse statements. So i'm restricted to logical and arithmetic operators. So far using the code below i've managed to make lists of…
0
votes
2 answers

Cannot find correct intersection of two string arrays when there is a comma in the strings

I have two CSV files: "userfeatures" and "itemfeatures". Each line in the userfeature is related to specific user. e.g., the first line in the userfeature file is: 005c2e08","Action","nm0000148","dir_ nm0764316","USA" I need to find the intersection…
mOna
  • 2,341
  • 9
  • 36
  • 60
0
votes
1 answer

Is resuse of vectors allowed in set_intersection?

I am little puzzled, here is what I did First vector named vec has 5 elements Second vector named s has 3 elements. Two elements are common to them Did a union of them, Got correct output. Result was stored in vec_out Problem begins -- 5. Did a…
mtk
  • 13,221
  • 16
  • 72
  • 112
0
votes
1 answer

MATLAB-making intersect faster

Let there be two arrays {A,B} of size 1xN I want to find the number of cases where on the same indices the condition A(ii)==1 & B(ii)==0 is satisfied. I tried casess= intersect( find(A==1),find(B==0 )) but this is very slow. I believe this is…
JohnnyF
  • 1,053
  • 4
  • 16
  • 31
0
votes
2 answers

Oracle Intersection of rows in a Table

Hi I have a table with two columns (WID,DT) with data.. WID DT ------- A 10 A 11 A 12 B 10 B 11 C 10 C 13 If I pass A,B in input i should get output as 10 and 11. Intersection of DT. If I pass A,B,C in input I should get 10 as…
user5073139
  • 1
  • 1
  • 1
0
votes
1 answer

What is the Pythonic way to iterate over set intersection and exclusions?

set_of_A_key and set_of_B_keyare two set of keys of dictionary dict_A and dict_B. I want operate over the dictionary values for the keys in the following three sets: (set_of_A_key & set_of_B_key), (set_of_A_key - set_of_B_key) and (set_of_B_key -…
nimeshkiranverma
  • 1,408
  • 6
  • 25
  • 48
0
votes
1 answer

Set-Intersection C++ using text file

I am currently writing a code to intersect two sets that are text files. I am new to C++ so there is bad coding. Please tell me what i am missing or mistype in this code. Thanks for helping me. set file1; set file2; set
SPSBE
  • 1
0
votes
1 answer

C++: How to use set_intersection on two vectors containing user-defined structs?

I have two vectors full of structs that are very simple: typedef struct{ //three vertex ids uint a,b,c; } Face; I'm currently trying to run set_intersection like…
0
votes
3 answers

Does set intersection guarantee a set of integers to be sorted?

I'm trying to do a huge amount of simple "intersection" operations with integers. Unfortunately, I do not have numpy/scipy available in the setup, and I'm not able to change that. I noticed on stackoverflow that the Python set operation nicely sorts…
PascalVKooten
  • 20,643
  • 17
  • 103
  • 160
0
votes
1 answer

Intersection with Java collection

I am looking many of the queries on how to get intersection set of 2 sets in a efficent time. And looking for very efficient way. Before approching my own way why can not ask Java to build a method to perform the same. Why Java has not build a…
Chowdappa
  • 1,580
  • 1
  • 15
  • 31
0
votes
1 answer

How can I visualize the intersection of two 3-D fields?

How can I visualize the intersection of two 3-D fields? I have the following functions 1. a*b*c ∈ [3,5]
 2. a/(b*c) ∈ [80,100] where a,b,c ∈ [0,100]. I am looking for the intersection of those 2 3-D-fields/bodies? I already found out how to…
0
votes
1 answer

Incorrect Calculation of Union and Intersection of Sets in Java

I've been writing functions that find the union and intersection of two sets in Java, but I appear to have a problem in my algorithm somewhere. For example, when I feed in the following two vectors of numbers: A = {0, 1, 3, 4, 5} B = {1, 1, 2, 3, 4,…
user3911542
  • 43
  • 1
  • 5
0
votes
1 answer

Trouble with set_union and set_intersection - C++

I am currently working on a project involving set calculations. I am using the functions set_union and set_intersection to calculate the union and intersection of sets. My variables are: int AunionB[8]; int AunionC[7]; //…