subject

Suppose you have two vector of integers x and y, each of which have N randomly distributed but distinctvalues. We want to merge x and y into a third vector z such that z has all the integers of x and y, additionally z should not have any duplicate values. For this problem we are not concerned with orderingin any of these vectors. a. Here is one algorithm. What is the Big-O of this algorithm?void merge1(const vector& x, const vector& y, vector& z) {z. clear();z. reserve(x. size() + y. size());for (int i = 0; i < x. size(); ++i)z. push_back(x[i]);for (int j = 0; j < y. size(); ++j) {bool duplicate = false;for (int i = 0; i < x. size(); ++i) {if (y[j] == x[i]) {duplicate = true;break;}}if (!duplicate)z. push_back(y[j]);}}b. Here is another algorithm that uses a sorting function, assume that the sort function is implemented asquicksort. What is this algorithm’s Big-O?void merge2(const vector& x, const vector& y, vector& z) {z. clear();z. reserve(x. size() + y. size());for (int i = 0; i < x. size(); i++)z. push_back(x[i]);for (int j = 0; j < y. size(); j++)z. push_back(y[j]);sort(z. begin(), z. end());int last = 0;for (int k = 1; k < z. size(); k++) {if (z[last] != z[k]) {last++;z[last] = z[k];}}z. resize(last + 1);}c. Which algorithm performs better given the provided description of inputs?d. Suppose the input vectors are:vector x{1,2,3,4,5,6,7,8,9,10,11,12,13,14, 15,16,17,18,19,20};vector y{21,22,23,24,25,26,27,28,29,30,31, 32,33,34,35,36,37,38,39};How will that change your analysis done in the previous parts?

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:30
On the loan worksheet in cell c9 enter pmt function to calculate the monthly payment for the altamonte springs 2018 facilities loan. ensure that the function returns a positive value and set the reference to cells b5 and b6 as absolute references.
Answers: 2
question
Computers and Technology, 22.06.2019 10:40
5. illustrate how fine-line inventory classification can be used with product and market segments. what are the benefits and considerations when classifying inventory by product, market, and product/market?
Answers: 2
question
Computers and Technology, 22.06.2019 22:40
Write a program that defines symbolic names for several string literals (chars between quotes). * use each symbolic name in a variable definition. * use of symbolic to compose the assembly code instruction set can perform vara = (vara - varb) + (varc - vard); ensure that variable is in unsigned integer data type. * you should also further enhance your symbolic logic block to to perform expression by introducing addition substitution rule. vara = (vara+varb) - (varc+vard). required: debug the disassembly code and note down the address and memory information.
Answers: 3
question
Computers and Technology, 23.06.2019 01:50
Create a class named majors that includes an enumeration for the six majors offered by a college as follows: acc, chem, cis, eng, his, phys. display the enumeration values for the user, then prompt the user to enter a major. display the college division in which the major falls. acc and cis are in the business division, chem and phys are in the science division, and eng and his are in the humanities division. save the file as majors.java.
Answers: 2
You know the right answer?
Suppose you have two vector of integers x and y, each of which have N randomly distributed but disti...
Questions
question
English, 28.01.2021 23:20
question
Physics, 28.01.2021 23:20
question
Mathematics, 28.01.2021 23:20
question
Health, 28.01.2021 23:20
Questions on the website: 13722363