
write a C++ function to compute the following (Set Theory)
a. std::
b. std::vector<int> union(std::vector<int>& a, std::vector<int>& b)
c. std::vector<int> abs_complement(std::vector<int>& u, std::vector<int>& a, std::vector<int>& b)
d. std::vector<int> relative_complement(std::vector<int>& u, std::vector<int>& a, std::vector<int>& b) //a\b
e. std::vector<int> delta_diff(std::vector<int>& u, std::vector<int>& a, std::vector<int>& b)
//a = { x, y, z ... }
void print(std::vector<int>& v, std::string& n) {
std::vector<int>::iterator itr = std::begin(v);
for (; itr != std::end(v); itr++) {
std::cout<<(*itr)<<std::endl;
}
}
int main(int avgc, char** avgs)
{
std::vector<int> u = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
std::vector<int> a = {1, 2, 3, 4, 5 };
std::vector<int> b = {4, 5, 6, 7, 8};
std::vector<int> ri = intersection(std::vector<int>& a, std::vector<int>& b);
print(ri);
std::vector<int> ru = union(std::vector<int>& a, std::vector<int>& b);
print(ri);
std::vector<int> ra = abs_complement(std::vector<int>& u, std::vector<int>& a, std::vector<int>& b);
print(ri);
std::vector<int> rr = relative_complement(std::vector<int>& u, std::vector<int>& a, std::vector<int>& b); \\a\b
print(ri);
std::vector<int> rd = delta_diff(std::vector<int>& u, std::vector<int>& a, std::vector<int>& b);
return 0;
}

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- Consider the following structure definition. Write a C/C++ function that takes an array of struct student with its size and applies a curve system like if the student scored below 50, 1dd 10 points, if it is above 50, add 2 points. The lowest possible mark is 0 and the highest possible mark is 10. struct student{ int ID; int score; void applycurve (struct student a[ ], int size)arrow_forwardCreate a flowchart for this program in c++, #include <iostream>#include <vector> // for vectors#include <algorithm>#include <cmath> // math for function like pow ,sin, log#include <numeric>using std::vector;using namespace std;int main(){ vector <float> x, y;//vector x for x and y for y float x_tmp = -2.5; // initial value of x float my_function(float x); while (x_tmp <= 2.5) // the last value of x { x.push_back(x_tmp); y.push_back(my_function(x_tmp)); // calculate function's value for given x x_tmp += 1;// add step } cout << "my name's khaled , my variant is 21 ," << " my function is y = 0.05 * x^3 + 6sin(3x) + 4 " << endl; cout << "x\t"; for (auto x_tmp1 : x) cout << '\t' << x_tmp1;//printing x values with tops cout << endl; cout << "y\t"; for (auto y_tmp1 : y) cout << '\t' << y_tmp1;//printing y values with tops…arrow_forwardComplete the C++ code below#include "std_lib_facilities.h"/*1. Define a function which calculates the outer product of two vectors. The function return is a matrix. */vector<vector<int>> outerProduct(vector<int>& A, vector<int>& B){//implement here}/*2. Define a function which transposes a matrix. */vector<vector<int>> transpose(vector<vector<int>>& A){//implementation}/*3. Define a function which calculates the multiplication of a matrix and it's transpose. */vector<vector<int>> product(vector<vector<int>>& A){// implementation}/*4. Define a print out function that will print out a matrix in the following format:Example: a 3 by 4 matrix should have the print out:1 2 3 42 3 4 53 4 5 6*/void printMatrix(vector<vector<int>>& A){// implementation}int main(){// Define both vector A and vector Bvector<int> A = {1 ,2, 3, 4, 5};vector<int> B = {1, 2, 3};/*Test outerProduct…arrow_forward
- need help in C++ Problem: You are asked to create a program for storing the catalog of movies at a DVD store using functions, files, and user-defined structures. The program should let the user read the movie through the file, add, remove, and output movies to the file. For this assignment, you must store the information about the movies in the catalog using a single vector. The vector's data type is a user-defined structure that you must define on functions.h following these rules: Identifier for the user-define structure: movie. Member variables of the structure "movie": name (string), year (int), and genre (string). Note: you must use the identifiers presented before when defining the user-defined structure. Your solution will NOT pass the unit test cases if you do not follow the instructions presented above. The main function is provided (you need to modify the code of the main function to call the user-defined functions described below). The following user-defined functions are…arrow_forwarda function that gets an array and return the element's average and variance in c needs to be separate function called to mainarrow_forwardC++arrow_forward
- Write the following function #input: a numerical vector x #output:the normalized vector, i.e. the vector rescaled into [0,1] # the formula to normalize is (x-min(x))/ (max(x)-min(x)) # you can NOT use the functions min and max # you can use %%, nrow, ncol, and length # you can write multiple functionsarrow_forwardC++ Create a function append(v1, v2) that adds a copy of all the elements of vector v1 to the end of vector v2. The arguments are vectors of integers. Write a test driver.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





