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, 21.06.2019 21:30
Apower user needs you to install a second type of operating system on his computer to increase efficiency while running some specialized software programs. which installation technique should you use?
Answers: 3
question
Computers and Technology, 22.06.2019 13:30
In which phase does software coding and testing happen in the spiral model? the spiral model does not have a separate testing phase. both, software coding and testing occurs during the phase.
Answers: 3
question
Computers and Technology, 23.06.2019 15:30
1. ask the user how many questions are in the quiz. 2. ask the user to enter the key (that is, the correct answers). there should be one answer for each question in the quiz, and each answer should be an integer. e.g., 34 7 13 100 81 3 9 10 321 12 might be the key for a 10-question quiz. you will need to store the key in an array. 3. ask the user to enter the answers for the quiz to be graded. there needs to be one answer for each question. note that these answers do not need to be stored; each answer can simply be compared to the key as it is entered. 4. when the user has entered all of the answers to be graded, print the number correct and the percent correct. 5. add a loop so that the user can grade any number of quizzes with a single key. after the results have been printed for each quiz, ask "grade another quiz? (y/n)." note: you only have one array (the key). you are not creating a new key for each set of quiz answers.
Answers: 3
question
Computers and Technology, 23.06.2019 17:30
Scientists have changed the model of the atom as they have gathered new evidence. one of the atomic models is shown below. what experimental evidence led to the development of this atomic model from the one before it? a few of the positive particles aimed at a gold foil seemed to bounce back. the colors of light emitted from heated atoms had very specific energies. experiments with water vapor showed that elements combine in specific proportions. cathode rays were bent in the same way whenever a magnet was brought near them.
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
Mathematics, 14.12.2020 19:40
question
Mathematics, 14.12.2020 19:40
question
Biology, 14.12.2020 19:40
question
Mathematics, 14.12.2020 19:40
question
Mathematics, 14.12.2020 19:40