Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I just need a List.h and a shot of the whole output. (Lab4Main.cpp) (Random.h) (Random.cpp) Just need: List.h Screen shot of entire output on terminal

I just need a List.h and a shot of the whole output.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

(Lab4Main.cpp)

image text in transcribed

image text in transcribed

image text in transcribed

(Random.h)

image text in transcribed

(Random.cpp)

image text in transcribed

image text in transcribed

image text in transcribed

Just need:

List.h

Screen shot of entire output on terminal

Implement and test the ADT List from the lecture videos and textbook Chapter 3. You will only be responsible for the coding of file List.h. All other files are provided. Start by downloading these files: Random.h and Random.cpp Lab4Main.cpp With a working List implementation in file List.h, the running program will produce the following kind of output: My list of random numbers: -73 73 -36 29 -81 72 22 -28 66 -34 -67 93 39 34 95 -56 76 41 73 7 -97 -51 -51 -97 -95 The max subseq sum: 433 The max subsum squence: 72 22 -28 66 -34 -67 93 39 34 95 -56 76 41 73 7 My list after replacing all max subseg values with 0: -73 0 -36 29 -81 O O OOOOOOOOO000 g -97 -51 -51 -97 -95 One more time, we are seeing a maximal subsequence sum problem; the program determines the maximal subsequence, prints out the values of this sequence, and replaces (via erase+insert) each value in this subsum sequence with value 0. Since this program generates a list of random numbers (see files Random.h,.cpp), everyone's output is likely differ, with a sequence of Os in a different segment of sequence. When you code our class List, make sure that you include these three (without comment, to keep compiler happy): List(List&& rhs) : thesize{ rhs.thesize }, head{ rhs.head }, tail{ rhs.tail } { rhs.theSize = 0; rhs.head = nullptr; rhs.tail = nullptr; // keep for compiler List& operator= (List&& rhs) { std:: swap(theSize, rhs. theSize); std:: swap(head, rhs.head); std:: swap(tail, rhs.tail); return *this; } clear the list by remove all values; woid clear() { while( !empty()) pop_front(); } This program is different from others you have written for CSE 2020 in that the code is spread out over multiple.cpp files. This has consequences on how to compile for those of you who work under Linux. With Linux, compile the.cpp files separately and link them into the executable as follows: g++ -c Random.cpp g++ -c Lab4Main.cpp g++ Random.o Lab4Maino Then run with ./a.out Under Visual Studio C++, none of this is necessary. All you do is place all.h files in the 'Header Files' folder and all.cpp files in the 'Source Files' folder. Compile as usual. #include #include "Random.h" #include "List.h" using namespace std; template void print_list(List); List max_subseq_sum_collect(const List&, int&); int main() { List mylst; random_list(25, 1, 100, mylst, 4); cout maxsubseq = max_subseq_sum_collect(mylst, maxsubsum); #1 11 cout ::iterator itr1 = maxsubseq.begin(); for (; itri != maxsubseq.end(); ++itr1) { //cout ::iterator itr2 = mylst.begin(); while (itr2 != mylst.end() { if (*itr1 *itr2) { int togo = *itr2; itr2 = mylst.erase(itr2); mylst.insert(itr2, 0); //cout void print_list(List 1st) cout :: iterator itr; for (itr = lst.begin(); itr != lst.end(); ++itr) cout max_subseq_sum_collect(const List& 1st, int& max) { int maxsum - int localsum 0; List maxseq; List localseq; List:: const_iterator itr 1st.begin(); for (; itr != lst.end(); itr++) { localsum += *itr; localseq.push_back(*itr); if (localsum > maxsum) { maxsum - localsum; maxseq = localseq; } else if (localsum #include #include #include "List.h" using namespace std; void rand_seed(); int rand_int(int, int); void random_vector(int, int, int, vector int>&, int); void random_vector_norep(int, int, int, vector&, int); void random_list(int, int, int, List&, int); #endif #include #include #include "Random.h" using namespace std; void rand_seed) { int seed = static_cast int>(time()); srand(seed); } // random integer between a and b; int rand_int(int a, int b) { return a + rand() % (b - a + 1); } // n*10% chance of negative number; repeats allowed; // absolute value between from and upto; void random_vector(int k, int from, int upto, vector int>& v, int negs) { rand_seed(); v.clear(); int rnum; int rneg; for (int i = 1; i 0) { rneg = rand_int(1, 10); if (rneg // no repeated elements in vector v; void random_vector_norep(int k, int from, int upto, vector int>& v, int negs) { int next; rand_seed(); v.clear(); vector in(upto + 1, 0); while (v.size() 0) { rneg = rand_int(1, 10); if (rneg & 1st, int negs) { 1st.clear(); vector rnums; random_vector(k, from, upto, rnums, negs); for (int i = 0; i #include "Random.h" #include "List.h" using namespace std; template void print_list(List); List max_subseq_sum_collect(const List&, int&); int main() { List mylst; random_list(25, 1, 100, mylst, 4); cout maxsubseq = max_subseq_sum_collect(mylst, maxsubsum); #1 11 cout ::iterator itr1 = maxsubseq.begin(); for (; itri != maxsubseq.end(); ++itr1) { //cout ::iterator itr2 = mylst.begin(); while (itr2 != mylst.end() { if (*itr1 *itr2) { int togo = *itr2; itr2 = mylst.erase(itr2); mylst.insert(itr2, 0); //cout void print_list(List 1st) cout :: iterator itr; for (itr = lst.begin(); itr != lst.end(); ++itr) cout max_subseq_sum_collect(const List& 1st, int& max) { int maxsum - int localsum 0; List maxseq; List localseq; List:: const_iterator itr 1st.begin(); for (; itr != lst.end(); itr++) { localsum += *itr; localseq.push_back(*itr); if (localsum > maxsum) { maxsum - localsum; maxseq = localseq; } else if (localsum #include #include #include "List.h" using namespace std; void rand_seed(); int rand_int(int, int); void random_vector(int, int, int, vector int>&, int); void random_vector_norep(int, int, int, vector&, int); void random_list(int, int, int, List&, int); #endif #include #include #include "Random.h" using namespace std; void rand_seed) { int seed = static_cast int>(time()); srand(seed); } // random integer between a and b; int rand_int(int a, int b) { return a + rand() % (b - a + 1); } // n*10% chance of negative number; repeats allowed; // absolute value between from and upto; void random_vector(int k, int from, int upto, vector int>& v, int negs) { rand_seed(); v.clear(); int rnum; int rneg; for (int i = 1; i 0) { rneg = rand_int(1, 10); if (rneg // no repeated elements in vector v; void random_vector_norep(int k, int from, int upto, vector int>& v, int negs) { int next; rand_seed(); v.clear(); vector in(upto + 1, 0); while (v.size() 0) { rneg = rand_int(1, 10); if (rneg & 1st, int negs) { 1st.clear(); vector rnums; random_vector(k, from, upto, rnums, negs); for (int i = 0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

What is cost basis?

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago