Question: Please help with the following assignment! Code for Lab 2 is #ifndef MaxSumSum_hpp #define MaxSumSum_hpp #include #include #include #include #include //int main() { using namespace
Please help with the following assignment!


Code for Lab 2 is
#ifndef MaxSumSum_hpp
#define MaxSumSum_hpp
#include
#include
#include
#include
#include
//int main() {
using namespace std;
void rand_seed()
{
int seed = static_cast(time(0));
srand(seed);
}
int rand_int(int a, int b)
{
return a+ rand() % (b-a+1);
}
void random_vector(int k, int from, int upto, vector& v)
{
int rnum;
int r33;
for (int i=1; i
{
rnum =rand_int (from,upto);
r33 = rand_int (1,4);
if (r33 == 3)
v.push_back(-rnum);
else
v.push_back(rnum);
}
return;
}
int max_subseq_seq_sum_cube(const vector& vec, int&ops)
{
int maxSum = 0;
ops = 0;
for (int i = 0; i for (int j = i; j {
int thisSum = 0;
for (int k = i; k
{
thisSum += vec[k];
ops += 1;
}
if (thisSum > maxSum)
maxSum=thisSum;
}
return maxSum;
}
int max_subseq_sum_quad(const vector& vec, int&ops)
{
int maxSum = 0;
ops = 0;
for (int i = 0; i
{
int thisSum = 0;
for (int j = i; j
{
thisSum += vec[j];
ops +=1;
if (thisSum >maxSum)
maxSum = thisSum;
}
}
return maxSum;
}
int max_subseq_sum_lin(const vector& vec, int&ops)
{
int maxSum = 0;
int thisSum = 0;
ops = 0;
for (int i = 0; i
{
thisSum +=vec[i];
ops +=1;
if (thisSum > maxSum)
maxSum=thisSum;
else if (thisSum
thisSum = 0;
}
return maxSum;
}
#endif /* MaxSumSum_hpp */
#include
#include
#include "MaxSumSum.h"
using namespace std;
int main()
{
vector mynums;
int how_many;
cout
cin>> how_many;
cout
random_vector(how_many, 1, 50, mynums);
int no_ops = 0;
int maxsum1 = max_subseq_seq_sum_cube(mynums,no_ops);
cout
int maxsum2 = max_subseq_sum_quad(mynums,no_ops);
cout
int maxsum3 = max_subseq_sum_lin(mynums,no_ops);
cout
return 0;
}
Complete the ADT Vector implementation from Lab2 and add the following two functions to the Vector class 1. Member function void erase (int k) which removes the element at index k. 2. Member function void insert (int k, T x) f...] which inserts the new element x at index k. (The element that is at index k prior to insertion, as well as all other elements at higher-numbered indices are to move one position to the right.) Details of the processes behind both functions are depicted below Erase: Erase the element at index 3 in vector [2][4][6][?[10] [12][14] [16] Step-by-step 0 1 2 3 4 5 6 7 [2]4](6][81[101[12][14][16] [2]I4][6][101[10][12][141[16] [2]41 6][10][12][12][14][16] [2][4][6][10][12][141[141[16] [2][4][6][101[12][14][16][16] 12141161101 1211411661 .. [2]I4][6][101[121[14][16] DONE! Look at the example and realize the kinds of shifts (really, copies") that will have the desired effect. Also notice the duplicate element at the end and how it is removed in order to produce the final result. Your function should also handle the special case where the removal index is the index of the element at the highest index what will be the simplest way to accomplish this element's removal? (Hint: this function already exists). Complete the ADT Vector implementation from Lab2 and add the following two functions to the Vector class 1. Member function void erase (int k) which removes the element at index k. 2. Member function void insert (int k, T x) f...] which inserts the new element x at index k. (The element that is at index k prior to insertion, as well as all other elements at higher-numbered indices are to move one position to the right.) Details of the processes behind both functions are depicted below Erase: Erase the element at index 3 in vector [2][4][6][?[10] [12][14] [16] Step-by-step 0 1 2 3 4 5 6 7 [2]4](6][81[101[12][14][16] [2]I4][6][101[10][12][141[16] [2]41 6][10][12][12][14][16] [2][4][6][10][12][141[141[16] [2][4][6][101[12][14][16][16] 12141161101 1211411661 .. [2]I4][6][101[121[14][16] DONE! Look at the example and realize the kinds of shifts (really, copies") that will have the desired effect. Also notice the duplicate element at the end and how it is removed in order to produce the final result. Your function should also handle the special case where the removal index is the index of the element at the highest index what will be the simplest way to accomplish this element's removal? (Hint: this function already exists)