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
0 answers

default constructing a template argument type from a within template class

I have the following example of a custom specialization of the std::set_union<...> algorithm. I adapted the implementation from from http://en.cppreference.com/w/cpp/algorithm/set_union. The reason I need to customize the implementation is that I…
johnco3
  • 2,401
  • 4
  • 35
  • 67
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]; //…
0
votes
1 answer

std::set_union vector>

I want to compute the union between two vectors: std::vector> p1; std::vector> p2; The problem is that why is the union being done on the second element instead of first? the size of the union should be equal…
Hani Goc
  • 2,371
  • 5
  • 45
  • 89
0
votes
1 answer

What is the most efficient way to ge the top N items of the union of M sorted sets

Say you have 4 sorted sets with thousands and thousands of keys and scores. Since they are sorted sets, getting the top items can ben done in logaritmic time complexity. The easy way would be to take the union of the sets, and then get the top…
Pepijn
  • 4,145
  • 5
  • 36
  • 64
0
votes
0 answers

Set_Union giving runtime error

I've been working on a problem in which I've to take union of n sets and see if all the sets are disjoint. I'm using set_union A draft for my code is as follows: vector I; // Vector to store union of all sets vector >A; // Vectors…
CPPCoder
  • 155
  • 1
  • 1
  • 10
0
votes
1 answer

segfault set_union with object : std::set

Hello all :) I hope someone will have a solution or I will finally find ^^ Context I am a beginner in c++ so, object, template and iterator maybe I understand a little bit and make some changes but I am not able to manipulate it when it is…
user2964288
  • 83
  • 1
  • 11
0
votes
2 answers

C++ how to merge, union, intersect two object of Vector into the new third object?

I've been learning about Vector and can't finish some parts. My code and the description on below. The output should be like this : b1 size = 0 b1 beginning capacity = 10 b1 empty? 1 b2 size = 0 b2 beginning capacity = 10 b2 empty? 1 b1 : [] b2 :…
lawZ
  • 39
  • 1
  • 3
  • 9
0
votes
2 answers

Printing set using the copy function

The problem I am having is that I need to print the resulting set from the union_set function using the copy function. (So I am not allowed to just put output as the last term of the set_union function). I cannot seem to get the copy function to…
0
votes
1 answer

set union is not working

'left' is std::vector of std::set for each element in left(which is set), I am trying to do set union operation to another set by iterating over 'left'. Why is the following code not working. I am trying to do set union of the two sets. …
Utkrist Adhikari
  • 1,052
  • 3
  • 15
  • 42
0
votes
3 answers

Prolog - union doesn't check for duplicates or that the list is in order

I'm trying to write a union function in Prolog and I'm running into some trouble. I have looked up examples and listed the built in example for union but I am writing my own for an assignment. I have noticed some strange results when a list has…
user1897691
  • 2,331
  • 3
  • 14
  • 12
0
votes
1 answer

I have an issue with set.union (C++)

I'm trying to union two sets (in a vector). setA contains a, b. setB contains a, c. After union, result is supposed to contain a, b, c. However, the program is not working, it is having some kind of debug error. #include #include…
user1527877
  • 83
  • 1
  • 1
  • 5
-1
votes
2 answers

How to to check if any tuples inside one list are inside another list?

The trouble I'm having is that these tuples are inside a list of lists of lists as shown below: giantlist = [[[(0,2), (2,3), (4,5)],[(0,2), (3,4), (6,8)], [(3,4),(0,2)]]] So, my issue is trying to traverse through each list and find out if they…
jakebrah
  • 37
  • 2
-1
votes
1 answer

Linked List Implementation using dummy nodes

I am working on a project where i have to union and intersect two sets. I am using Linked list for each set with dummy nodes. This is how i initialize my Sets LL class public Set() { top = new Node(Integer.MIN_VALUE, new Node(Integer.MAX_VALUE,…
Saad
  • 399
  • 8
  • 25
-2
votes
1 answer

Find all groups of pairs with intersections C#

Given a list of pairs such as List pair1 = new List() { 1, 3}; List pair2 = new List() { 1, 2 }; List pair3 = new List() { 5, 3 }; List pair4 = new List() { 7, 8 }; …
D Sonnier
  • 1
  • 2
1 2 3 4 5
6