Question: // Need help with the following c++ code, just need help with filing the code, need code where * appears // Instructions : Void Combine

// Need help with the following c++ code, just need help with filing the code, need code where * appears

// Instructions : Void Combine will take 3 vectors as arguments: A, B and R.

// Combine should work for any size vectors as long as the size of A and B are the same.

// It will combine the elements of A and B into R to produce the sorted list R.

// You should know how to find the size of a vector.

// Display comparison every time an element-element comparison is done.

Your main()

  1. Will declare three vectors L1, L2 and L3.
  2. Will ask the user to type integers in increasing order into L1.
  3. Then ask the user to type more integers in increasing order into L2.
  4. Then it will call void Combine to combine L1 and L2 to produce L3 which is passed back by reference.
  5. Display what is in L3.

Required Test Cases: (Must test in this order)Text2.txt

  1. Combine 1 2 3 with 4 5 6
  2. Combine 1 3 5 with 2 4 6
  3. Combine 4 5 6 with 1 2 3
  4. Combine 1 2 5 6 with 3 4 7 8

// Code

using namespace std;

#include

#include

//--------------------------------------------

//CS311 HW2P2 Combine

//Name: **

//Compiler: g++

//--------------------------------------------

// combine two sorted lists A and B into R

// displays comparison every time it is done

void combine( vector<int> A, vector<int> B, vector<int> &R )

{

**

cout << "comparison" << endl;

** // be careful -- R comes in as an empty vector

}

int main()

{

vector<int> L1;

vector<int> L2;

vector<int> L3;

int N; // how many elements in each of L1 and L2

int e; // for each element

cout << "How many elements in each list?" << endl;

cin >> N;

cout << "List1" << endl;

for (int i = 1; i <=N; i++)

{ cout << "element :"; cin >> e; L1.push_back(e);}

cout << "List2" << endl;

for (int i = 1; i <=N; i++)

{ cout << "element :"; cin >> e; L2.push_back(e);}

// call combine here to combine L1 and L2 into L3

**

cout << "The result is: ";

for (int i = 0; i < N*2; i++)

{ cout << L3[i]; } cout << endl;

}// end of main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!